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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to make grid columns use 100% grid width

Thread ID:

Created:

Updated:

Platform:

Replies:

88334 Jul 20,2009 07:00 AM UTC Jul 21,2009 03:23 PM UTC WinForms 1
loading
Tags: GridControl
Tomasz Wasala
Asked On July 20, 2009 07:00 AM UTC

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

Rajadurai C [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;