
Make dbgrid columns width follow form width ???
You have to write down your own code.
In the Form_Resize event you have to recalculate the dimension of the
control
due to the change of the form size. Then you have to resize each column.
To work with the following example open a new project. On Form1 draw a
Dbgrid.
Set the Align property of Dbgrid1 to 1 (Align Top). Copy and paste the
following
code to the general declaration section of from1. And run.
Private Sub Form_Resize()
DBGrid1.Height = Height - 400
For Each Column In DBGrid1.Columns
Column.Width = (DBGrid1.Width - 330) \ DBGrid1.Columns.Count
Next Column
End Sub
Note that this example assumes each column has the same width as others.
Youll' ask why Height -400 and Dbgrid1.Width -330. Right ?
Well 400 is approximately the heigth of the caption bar of the window.
And 330 is approximately the width of the record selectors column in
dbgrid1.
Hope this helps to solve your problem.
Bye
Bj?rn J?nsson ha scritto:
Quote:
> Hi !
> Can anyone help me out here......
> I want the columns in a dbgrid follow the width in the form,
> if changing size width the columns should change so it
> fits the form...
> Tnx
> Bj?rn