resize DBG when data is smaller than grid

I have a databound grid about 400 pixels wide. I have t columns that are at most 100 pixels wide. RsizetoFit just resizes the columns to the largest width of each column (whih is 100 each) I want to have the DataBound columns equally fill the whole table width. how do I do this?

1 Reply

AD Administrator Syncfusion Team December 16, 2005 12:02 AM UTC

You can use code similar to the code below to set these colwidths.
int width = (grid.ClientSize.Width - grid.Model.ColWidths[0]) / grid.Model.ColCount;

for(int i = 1; i <= grid.Model.ColCount; ++i)
{
   grid.Model.ColWidths[i] = width;
}
Or if you want to do it dynamically through an event, you can use the grid.Model.QueryColWidth event. There if e.Index > 0, you set e.Size = width (as calculated above) and e.Handled = true. You can see code similar to this in the \Essential Studio\3.3.0.0\Windows\Grid.Windows\Samples\DataBound\GridDataBoundImageCell sample.

Loader.
Up arrow icon