joyrider
asked on
DBgrid columns
Hi,
i got an mdb access file, and i'm linking to it using a Tdatasource wich is connected to a TadoQuerry
and the dbgrid is connected to the Tdatasource
so i get my *wanted info* based on a querry and this is displayed in the dbgrid.
The columns are automaticly put in some order and the widths are also done automaticly, how can i do this manually io defining them in design time so they are for example all 50 pixels wide ?
i tried serveral things :
adding some columns using columns editor but then my info wasn't displayed anymore
activating the querry in design time and modifying the width but then i couldn't change all of the columns (those strings defined in the access file 255 chars)
and also when i ran the program it was all reset.
so my question is how can i predefine these column widths and the order they appear in etc
thanks
i got an mdb access file, and i'm linking to it using a Tdatasource wich is connected to a TadoQuerry
and the dbgrid is connected to the Tdatasource
so i get my *wanted info* based on a querry and this is displayed in the dbgrid.
The columns are automaticly put in some order and the widths are also done automaticly, how can i do this manually io defining them in design time so they are for example all 50 pixels wide ?
i tried serveral things :
adding some columns using columns editor but then my info wasn't displayed anymore
activating the querry in design time and modifying the width but then i couldn't change all of the columns (those strings defined in the access file 255 chars)
and also when i ran the program it was all reset.
so my question is how can i predefine these column widths and the order they appear in etc
thanks
This code will change all the colums in dbgrid to 50 width
procedure TForm1.Button1Click(Sender : TObject);
var
I : integer;
begin
for I := 0 to DBGrid1.Columns.Count -1 do
DBGrid1.Columns[I].Width := 50;
end;
procedure TForm1.Button1Click(Sender
var
I : integer;
begin
for I := 0 to DBGrid1.Columns.Count -1 do
DBGrid1.Columns[I].Width := 50;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok thanks changing at runtime & order is done in sql code :)
you can use EmptyDataSet,FieldDefs,Cre