We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to make grid columns use 100% grid width

Hello,

I have following problem. I created a form with GridDataboundGrid. When forms loads I fill grid from database dynamically.

The problem is that I dont know how to make grid use 100% width (stretch columns).
As you can see on screenshot the grid takes about 50% of width.
How can I make it use 100% width by default (even when there are more columns)?

Thanks for answer,
Tomasz Wąsala



screenshot_5f9b3dc1.jpg

1 Reply

RC Rajadurai C Syncfusion Team July 21, 2009 03:23 PM UTC

Hi Tomasz,

Thanks for your interest in Syncfusion Products.

There is no special property setting for this. However it can be achieved through the QueryColWidth event handler.

The following code achieves this feature.

void Model_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if (e.Index == this.gridDataBoundGrid1 .Model.ColCount)
{
int i = e.Index - 1;
int width = this.gridDataBoundGrid1.ClientSize.Width - this.gridDataBoundGrid1.Model.ColWidths[0];
while (i > 0 && width - this.gridDataBoundGrid1 .Model.ColWidths[i] > 0)
{
width -= this.gridDataBoundGrid1 .Model .ColWidths[i];
--i;
}
e.Size = width;
e.Handled = true;
}
}

You can handle this event through the following code in Form_Load event.

this.gridDataBoundGrid1.Model.QueryColWidth += new GridRowColSizeEventHandler(Model_QueryColWidth);


Regards,
Rajadurai

Loader.
Live Chat Icon For mobile
Up arrow icon