Add controls to webgridpanel, how to change column width

Hi,

The following code is used to add controls to a webgridpanel. This is working but how can the width of each colum be changed at runtime?

wgpFields.BeginUpdate;

wgpFields.ColumnCollection.Add;
wgpFields.ColumnCollection.Add;

wgpFields.RowCollection.Add;
lbl := TWebLabel.Create(Self);
lbl.Caption := 'ID';
lbl.Parent := wgpFields;
wgpFields.AddControl( lbl );

edt:= TWebDBEdit.Create(Self);
edt.DataField := 'ID';
edt.Parent := wgpFields;
wgpFields.AddControl(edt);

wgpFields.RowCollection.Add;
lbl := TWebLabel.Create(Self);
lbl.Caption := 'FIRST_NAME';
lbl.Parent := wgpFields;
wgpFields.AddControl( lbl );

edt:= TWebDBEdit.Create(Self);
edt.DataField := 'FIRST_NAME';
edt.Parent := wgpFields;
wgpFields.AddControl(edt);

wgpFields.RowCollection.Add;
lbl := TWebLabel.Create(Self);
lbl.Caption := 'LAST_NAME';
lbl.Parent := wgpFields;
wgpFields.AddControl( lbl );

edt:= TWebDBEdit.Create(Self);
edt.DataField := 'LAST_NAME';
edt.Parent := wgpFields;
wgpFields.AddControl(edt);

wgpFields.BeginUpdate;

Similar like the webgridpanel demo, only difference is creating and adding during runtime.

The width of a column is controlled by

WebGridPanel.ColumnCollection[index].SizeStyle
WebGridPanel.ColumnCollection[index].Value

If you want it to be an absolute with, set SizeStyle to ssAbsolute and the Value to the desired width in pixels.

Thank you for the explanation.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.