Fórum DBGrid #175938
19/08/2003
0
Numa consulta normal num DBGrid, existe o ponteiro na coluna fixa (1ª coluna do Grid) que aponta pro registro atual. Gostaria de saber se tem como eu mudar a fonte do registro atual do grid, por exemplo. gostaria de deixar em negrito o registro que está sendo apontado pelo cursor! pra facilitar pro usuário a visualização e localização do ponteiro.
Grato pela força!!!
:)
Grato pela força!!!
:)
Maximus
Curtir tópico
+ 0
Responder
Posts
19/08/2003
Afarias
Utilize o evento OnDrawColumnCell do DBGrid para realizar qualquer formatação nos valores apresentados.
Vou dar um exemplo abaixo más aconcelho procurar os diversos códigos de exemplo existentes na net sobre o uso deste evento (desenhando um DBGrid) -- dá algum trabalho usar o evento más vc pode fazer de tudo!!
Ex::
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
X, Y: Integer;
TextData: string;
begin
with (Sender as TDBGrid).Canvas do
begin
if (gdSelected in State) then
begin
Brush.Color := clInfoBk;
FillRect(Rect);
Font.Color := clInfoText;
Font.Style := [fsBold];
TextData := Column.Field.AsString;
case Column.Alignment of
taLeftJustify: begin
X := Rect.Left+2;
Y := Rect.Top+2;
end;
taRightJustify:begin
X := Rect.Right-(TextWidth(TextData) + 2);
Y := Rect.Top+2;
end;
taCenter: begin
X := Rect.Left+(((Rect.Right - Rect.Left) - TextWidth(TextData)) div 2);
Y := Rect.Top+2;
end;
end;
TextRect(Rect, X, Y, TextData);
end;
end;
end;
Vou dar um exemplo abaixo más aconcelho procurar os diversos códigos de exemplo existentes na net sobre o uso deste evento (desenhando um DBGrid) -- dá algum trabalho usar o evento más vc pode fazer de tudo!!
Ex::
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
var
X, Y: Integer;
TextData: string;
begin
with (Sender as TDBGrid).Canvas do
begin
if (gdSelected in State) then
begin
Brush.Color := clInfoBk;
FillRect(Rect);
Font.Color := clInfoText;
Font.Style := [fsBold];
TextData := Column.Field.AsString;
case Column.Alignment of
taLeftJustify: begin
X := Rect.Left+2;
Y := Rect.Top+2;
end;
taRightJustify:begin
X := Rect.Right-(TextWidth(TextData) + 2);
Y := Rect.Top+2;
end;
taCenter: begin
X := Rect.Left+(((Rect.Right - Rect.Left) - TextWidth(TextData)) div 2);
Y := Rect.Top+2;
end;
end;
TextRect(Rect, X, Y, TextData);
end;
end;
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)