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

Setting all column with to "best fit"

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

3 Replies

MK Muthukumar Kalyanasundaram Syncfusion Team January 18, 2015 01:25 PM UTC

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



MH Matthias Heyberg January 19, 2015 02:03 PM UTC

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




MK Muthukumar Kalyanasundaram Syncfusion Team January 21, 2015 04:39 AM UTC

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

Loader.
Live Chat Icon For mobile
Up arrow icon