changing the width columns

A client is having some problems working the component DBGrid. He has some fields that are smaller
                  or bigger than the default width columns so he enter to the Columns editor and change the property
                  width, and the columns changes, but if he saves and close the Delphi, restart Delphi and reopen the
                  project the columns are with the default width, again.

                  So he has kept the columns with that size but the interface isn't OK, because there are grids with 50

                  Do you know anything about it ??
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You could save the column widths in a file and simply load them at run time. That way whenever the user changes the column width at runtime you can save the column widths to the file and next time it runs theye are exactly as he/she left them

The Neil
Is the width of the column header/title, less than the width he is setting the column to?
Try this out.. it's sneaky, but it does the job:

var colwidth:integer;

Good luck!!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

to drdelphi,

>Good luck!!

yup, i guess this is needed,
because is the field is empty then will the width be 0 :-(

better would be something like this
dbgrid1.columns[index].Width := dbgrid1.columns[index].Field.Displaywidth; //+ maybe a bit additional offset

but the best solution is already commented by the neil by storing the width by iterating through the columns in a file at app-end and read and set at app start, then the client can do what he want with the grid-column width.

arocioAuthor Commented:
Well, the point isn't like that, because the problem is that never it keeps the width the developer gives.
I will ammend my answer to suit :

var I:integer;
For I:=0 to 3 do
if length(Fields[i].AsString)>20
  then Fields[i].DisplayWidth:=Length Fields[i].AsString)

This will give you a set minimun width, changing only when the field requires it.

Good luck!!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.