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.
Unfortunately, activation email could not send to your email. Please try again.

Setting all column with to "best fit"

Thread ID:

Created:

Updated:

Platform:

Replies:

117962 Jan 13,2015 05:26 PM Jan 20,2015 11:39 PM Windows Forms 3
loading
Tags: GridGroupingControl
Matthias Heyberg
Asked On January 13, 2015 05:26 PM

Hey,

how can one set the width of all columns to optimum size? There must be an easier way than to handle the resize event.

Regards,
Matthias

Muthukumar Kalyanasundaram [Syncfusion]
Replied On January 18, 2015 08:25 AM

Hi Matthias,

 

Thank you for your interest in Syncfusion products.

 

If you want to set all column as same width in a grid, you can use “QueryColWidth” event. Using this event and set the size by Size property.  Please refer the below code,

 

Code:

 

this.gridGroupingControl1.TableModel.QueryColWidth += new GridRowColSizeEventHandler(TableModel_QueryColWidth);

 

void TableModel_QueryColWidth(object sender, GridRowColSizeEventArgs e)

{

e.Size = 20;

e.Handled = true;

}

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Matthias Heyberg
Replied On January 19, 2015 09:03 AM

Hi Muthukumar,

thanks for your reply. This would set all columns to a fixed width of 20px. Not quite what I want to achive. I want the width of all columns to fill the space of  the grid control. Width of each column should be subject to the columns content. In other words, I dont want empty space inside the grid.

Best Regards,

Matthais



Muthukumar Kalyanasundaram [Syncfusion]
Replied On January 20, 2015 11:39 PM

Hi Matthias,

 

Thank you for your interest in Syncfusion products.

 

We have implemented generic classes(helper classes) named as GridColSizingHelper. The GridColSizingHelper class includes the customization for column width resizing according to client size. Please refer the below code to wire the Grid to the helper classes,

 

Code Snippet:

private GridColSizingHelper Helper1;

private void Form1_Load(object sender, EventArgs e)

{

Helper1 = new GridColSizingHelper();

Helper1.WireGrid(this.gridControl1);

}

 

Please let us know if you have any concern.

 

Regards,

Muthukumar K


Attachment: ResizeHelper_74002724.zip

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.

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.

;