Link to home
Start Free TrialLog in
Avatar of Fled
Fled

asked on

How to set fixedRows in DBGrid component

Hi,
I have a form with a dbgrid displaying some information. I need to set a status colon as a fixedrow. I did it with stringGrid component but i m not able to do it with DBGrid. Any help
Thanks
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Ylu *can* use a "class cracker" like this:

type
  TMyDBGrid = class(TDBGrid);

procedure TForm1.Button1Click(Sender: TObject);
begin
  TMyDBGrid(DBGrid1).FixedCols := 2;
end;


But, you are also going to have to override the OnDrawColumnCell and rework the
painting of the fixed columns.
Avatar of Fled
Fled

ASKER

This does not work in Delphi7 with XP computer. No matter for  what it is displayed in the fixed Colones.
Thanks
This doesn't make sense: "I need to set a status colon as a fixedrow"

Make a Column a fixed ROW?

Please explain further what you want or did with TStringGrid.
Avatar of Fled

ASKER

Yes fixedCol instead of fixedRow. Sorry :)
The code I showed MADE A FIXED COLUMN. You will need to override the OnDrawColumnCell  to
rework the drawing of the cells, though.
Avatar of Fled

ASKER

I left the OnDrawColumnCell to the default, does not matter what is displayed in the cell, I expect to get an empty Fixed column with your code but it does nothing in delphi7. Did you test it with this version of delphi?
Thank you.
Yes, I wrote it using Delphi 7. The Fixed column should contain the data that is in the second column.
I was unaware that you wanted an EMPTY fixed column. If that's the case, we'll do something different.
Avatar of Fled

ASKER

The First cell of the fixed column (Title cell) does not look like the others cells. I mean it s white with out caption.
Thanks
You have to remember that TDBGrid is designed to work a specific way. To override the behavior of how
the cells are drawn, you will have to override the protected DrawCell method in a descendant.
Avatar of Fled

ASKER

Do you mean that I must create a descendant of TDBGrid to have a fixed column? no way else? it seems hard
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Eddie Shipman
Eddie Shipman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial