Hola BlueSteel.
Si te entendí bién, este código debería hacer lo que buscas. Lo asigné al evento
OnClick de un
TButton, pero vos podés ponerlo en el evento
que te convenga para el caso.
Hice en el DataSet un campo calculado que bauticé:
Q_IngresoGralPintarGrid (en honor al DataSet
) y usé el editor de columnas del DBGrid
para evitar visualizarlo. Un
TEdit recibe el dato que se le pasará al
Locate en el evento
OnClick del
TButton.
Código Delphi
[-]
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if AQ_IngresoGralPintarGrid.Value then
begin
DBGrid1.Canvas.brush.Color:= clBlue;
DBGrid1.Canvas.Font.Color:= clWhite;
end
else
begin
DBGrid1.Canvas.Brush.Color:= clWindow;
DBGrid1.Canvas.Font.Color:= clBlack;
end;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State)
end;
Llamada:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
begin
AQ_IngresoGral.Locate('NOMBRE', Edit1.Text, []);
AQ_IngresoGral.Edit;
AQ_IngresoGralPintarGrid.Value:= True;
end;
El código deja pintada la fila en que te ubicaste con
Locate hasta que realices un nuevo posicionamiento, sin que haya necesidad de darle
el foco al
TDBGrid.
Un saludo.