Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 08-11-2013
Avatar de jafera
jafera jafera is offline
Miembro
 
Registrado: may 2007
Ubicación: Llagostera (Girona)
Posts: 585
Poder: 20
jafera Va por buen camino
Foco a dbgrid

Buenas de nuevo compañeros.

Os quiero comentar un problema que tengo con el foco a un dbgrid (satandart de la paleta data controls) y que llevo dos días de craneo sin encontrar la solución.
Se trata de que al entrar en el susodicho dbgrid que solo tiene dos columnas, el foco me vaya a una columna determinada ya que la otra esta puesta como solo lectura para que el usuario no me la modifique.
Este dbgrid esta dentro de un pagecontrol y al entrar el mismo pongo el siguiente código:
Código Delphi [-]
 
procedure TF_EntradaPuntuacions.TabSheet1Enter(Sender: TObject);
begin
        DBGrid1.SelectedField.FieldName:='Volta_1PUNTS';
end;
Al entrar me da error de que no se puede realizar la operacion en un dataset abierto.

Para acceder a este formulario hago la llamada siguiente:

Código Delphi [-]
 
procedure TF_EntradaPuntuacions.Edit1Exit(Sender: TObject);
var v:string;
begin
        SQLInscrits.Close;
        SQLInscrits.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
        SQLInscrits.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
        SQLInscrits.Open;
        v:=InputBox('Volta?', 'Volta','');
        if StrToInt(v)>F_ModulDades.CursaNUM_VOLTES.Value then
        begin
                ShowMessage('Aquesta cursa nomes té '+IntToStr(F_ModulDades.CursaNUM_VOLTES.Value)+' voltes');
                repeat
                        v:=InputBox('Volta?', 'Volta','');
                until
                StrToInt(v)<=F_ModulDades.CursaNUM_VOLTES.Value;
                begin
                        Volta_1.Close;
                        Volta_1.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                        Volta_1.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                        Volta_1.ParamByName('VOLTA').AsInteger:=1;
                        Volta_1.Open;
                        Volta_2.Close;
                        Volta_2.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                        Volta_2.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                        Volta_2.ParamByName('VOLTA').AsInteger:=2;
                        Volta_2.Open;
                        Volta_3.Close;
                        Volta_3.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                        Volta_3.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                        Volta_3.ParamByName('VOLTA').AsInteger:=3;
                        Volta_3.Open;
                        Volta_4.Close;
                        Volta_4.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                        Volta_4.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                        Volta_4.ParamByName('VOLTA').AsInteger:=4;
                        Volta_4.Open;
                        Volta_5.Close;
                        Volta_5.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                        Volta_5.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                        Volta_5.ParamByName('VOLTA').AsInteger:=5;
                        Volta_5.Open;
                        if StrToInt(v)=1 then
                        begin
                                PageControl1.ActivePage:=TabSheet1;
                                DBGrid1.SetFocus;
                                Volta_1.Edit;
                        end;
                        if StrToInt(v)=2 then
                        begin
                                PageControl1.ActivePage:=TabSheet2;
                                DBGrid2.SetFocus;
                                Volta_2.Edit;
                        end;
                        if StrToInt(v)=3 then
                        begin
                                PageControl1.ActivePage:=TabSheet3;
                                DBGrid3.SetFocus;
                                Volta_3.Edit;
                        end;
                        if StrToInt(v)=4 then
                        begin
                                PageControl1.ActivePage:=TabSheet4;
                                DBGrid4.SetFocus;
                                Volta_4.Edit;
                        end;
                        if StrToInt(v)=5 then
                        begin
                                PageControl1.ActivePage:=TabSheet5;
                                DBGrid5.SetFocus;
                                Volta_5.Edit;
                        end;
                end;
        end
        else
        begin
                Volta_1.Close;
                Volta_1.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                Volta_1.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                Volta_1.Open;
                Volta_2.Close;
                Volta_2.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                Volta_2.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                Volta_2.Open;
                Volta_3.Close;
                Volta_3.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                Volta_3.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                Volta_3.Open;
                Volta_4.Close;
                Volta_4.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                Volta_4.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                Volta_4.Open;
                Volta_5.Close;
                Volta_5.ParamByName('CURSA').AsInteger:=F_ModulDades.CursaID_CURSA.Value;
                Volta_5.ParamByName('DORSAL').AsInteger:=StrToInt(Edit1.Text);
                Volta_5.Open;
                if StrToInt(v)=1 then
                begin
                        PageControl1.ActivePage:=TabSheet1;
                        DBGrid1.SetFocus;
                        Volta_1.Edit;
                end;
                if StrToInt(v)=2 then
                begin
                        PageControl1.ActivePage:=TabSheet2;
                        DBGrid2.SetFocus;
                        Volta_2.Edit;
                end;
                if StrToInt(v)=3 then
                begin
                        PageControl1.ActivePage:=TabSheet3;
                        DBGrid3.SetFocus;
                        Volta_3.Edit;
                end;
                if StrToInt(v)=4 then
                begin
                        PageControl1.ActivePage:=TabSheet4;
                        DBGrid4.SetFocus;
                        Volta_4.Edit;
                end;
                if StrToInt(v)=5 then
                begin
                        PageControl1.ActivePage:=TabSheet5;
                        DBGrid5.SetFocus;
                        Volta_5.Edit;
                end;
        end;
end;

En el edit1 coloco el dorsal del corredor a buscar y compruebo que el numero de vueltas no sea superior al estipulado, de ahí la comprobación "until".
Otra cosa que no se es si esta es la forma más ortodoxa de realizar la comprobación ya que duplico el código.

En fin si alguien me sugiere algo pues muchisimas gracias.

Saludos

Josep
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Pasar el foco a la primer columna del DBGrid... JairoC Varios 2 19-10-2011 00:05:07
Como quitar el foco de un DBGRID NeoNew Varios 4 04-04-2009 01:45:07
Pasando el foco de un DBGrid RoyTan Conexión con bases de datos 4 11-01-2008 20:54:15
Controlar el foco dentro de un DBGrid chileno Conexión con bases de datos 6 19-09-2006 17:15:31
Foco en DBGRID DE LAS RXLIB 2.75 serhasae Varios 2 26-06-2004 16:05:41


La franja horaria es GMT +2. Ahora son las 06:47:04.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi