DBGrid columns

Dave_B_C
Dave_B_C used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
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.

Commented:
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
Commented:
for addition:
after you "add fields" you could arrange the DBGrid's columns as you wish since this width information will be kept on Field's information.

Regards,
Dewo

Author

Commented:
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

Commented:
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

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial