Components for Delphi and C++ Builder.

Go to Russian forum
Go to EhLib.com
It is currently 19 Apr 2024, 13:41

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 27 Sep 2019, 20:20 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 91
I have this code below to change the color of the grid.

Code:
procedure TForm1.OnGridColumnsGetCellParams(Sender: TObject; EditMode: Boolean; Params: TColCellParamsEh);
begin
if (gdRowSelected in Params.State) then begin
  Params.Background := clYellow;
  Params.Font.Color := clBlack;

  Params.SuppressActiveCellColor := True;
end;

end;

procedure TForm1.Button1Click(Sender: TObject);
Var E: Integer;
begin
For E := 0 To GridDados.Columns.count - 1 do
  GridDados.Columns[E].OnGetCellParams := OnGridColumnsGetCellParams;

end;


but if I put the Grid in edit mode back to Blue Default how to change the focus edit too to clYellow ?

Code:
procedure TForm1.Button2Click(Sender: TObject);
begin
GridDados.Options := GridDados.Options - [dgRowSelect];
GridDados.Options := GridDados.Options + [dgEditing];
end;


Top
 Profile  
 
PostPosted: 28 Sep 2019, 17:44 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

Could you send full version of your Demo? pas+dfm+dpr?

I can not understand your statement:
Quote:
but if I put the Grid in edit mode back to Blue Default how to change the focus edit too to clYellow ?


If your columns are dynamic then they will be recreated when the DataSet is reopened.
In this case, you will need to reassign the event.

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
PostPosted: 30 Sep 2019, 11:47 
Offline

Joined: 13 Jul 2019, 19:08
Posts: 91
Example project with a video explaining better

https://mega.nz/#!E6Ii3CrK!qxhb1oFy3Fo1WhxeNeyVCr6Ka8d3VrEPTQ7YbXDwPrI


Top
 Profile  
 
PostPosted: 30 Sep 2019, 22:52 
Offline

Joined: 08 May 2014, 18:06
Posts: 663
Hello

Add (gdSelected in Params.State) to the OnGridColumnsGetCellParams method like this:

Code:
procedure TForm1.OnGridColumnsGetCellParams(Sender: TObject; EditMode: Boolean; Params: TColCellParamsEh);
begin
if (gdRowSelected in Params.State)
or (gdSelected in Params.State) then
begin
  Params.Background := clYellow;
  Params.Font.Color := clBlack;
  Params.SuppressActiveCellColor := True;
end;
end;


When dgRowSelect is not Grid.Options then gdSelected value is used instead of gdRowSelected .

_________________
Best regards
EhLib Support Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group