Link to home
Start Free TrialLog in
Avatar of Dave_B_C
Dave_B_C

asked on

DBGrid columns

I have a program that displays Access table data via a DBGrid. I have diligently changed the field column widths in the grid so the row fits the window, but when I run the program it displays with column widths bearing no resemblance to those I put in! They do not match those used in native Access either. How do I prevent this?

Dave
Avatar of PhilaDelphi
PhilaDelphi

You can apply your changes to the columns at run-time after your table/query becomes active.

example :

DBGrid1.Columns[0].Width := 100;  // where 0 is the first column in the grid.
Did you already "Add Fields" on Fields Editor (from TDataset and it's descendant components)?
With this you could set the columns width manually on design time.

Regards,
Dewo
ASKER CERTIFIED SOLUTION
Avatar of dewo
dewo

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
Avatar of Dave_B_C

ASKER

I already did what you suggested Dewo... What seems to happen is that if you change the width at design time to be less thn the column header, it overrides this at execution time and sets the column width to be the width of the label + a space. Now I know this I can live with it, but thanks for your help anyway!

If I get desperate I'll try Phili's suggestion, but for now I'll just jugglee things at design time..

Dave
O, I see, the real problem is because you try to set the column width less than it's caption width. Why are you not change the caption with the shorter one? :)

Regards, Dewo