arocio
asked on
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
columns.
Do you know anything about it ??
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
columns.
Do you know anything about it ??
Is the width of the column header/title, less than the width he is setting the column to?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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].Wid th := dbgrid1.columns[index].Fie ld.Display width; //+ 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.
meikl
>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].Wid
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.
meikl
ASKER
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;
begin
For I:=0 to 3 do
if length(Fields[i].AsString) >20
then Fields[i].DisplayWidth:=Le ngth Fields[i].AsString)
Else
Fields[i].DisplayWidth:=20 ;
end;
This will give you a set minimun width, changing only when the field requires it.
Good luck!!
var I:integer;
begin
For I:=0 to 3 do
if length(Fields[i].AsString)
then Fields[i].DisplayWidth:=Le
Else
Fields[i].DisplayWidth:=20
end;
This will give you a set minimun width, changing only when the field requires it.
Good luck!!
The Neil