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 : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Autosize column headers

Thread ID:

Created:

Updated:

Platform:

Replies:

78128 Dec 1,2008 11:52 AM UTC Dec 15,2008 12:56 PM UTC WinForms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On December 1, 2008 11:52 AM UTC

Hi.
I want to column headers size is changing due GridControl size. Is it possible? Could you help me?



Nisha Arockiya A [Syncfusion]
Replied On December 2, 2008 12:41 PM UTC


Hi Dmitry,

Thanks for your interest in Syncfusion Products.

The style AutoSize property only works as your user types text into a cell. If AUtoSize is et to true for a cell, the cell will grow as your user types longer words.

To programmatically size a column, you use the GridControl.ColWidths.ResizeToFit method. (Or, GridDataBoundGrid.Model.ColWidths.ResizeToFit).
So, after setting your titles, try code such as:

this.grid.ColWidths.ResizeToFit(GridRangeInfo.Row(0), GridResizeToFitOptions.None);


to resize row zero which are the column headers.

Let me know if this is not what you needed.

Regards,
Nisha


Administrator [Syncfusion]
Replied On December 11, 2008 12:26 PM UTC

Hi.

Thank you for your answer.
But I want to change column size in automatic mode when grid change its size. For example:
We have a Form and one GridControl on it.
GridControl.DockStyle = DockStyle.Fill.
Grid control has 3 columns: col1, col2, col3.
When user changes size of this form, size of grid control is changed either.
I want that col2 size and col3 size are not changed but col1 must fill all free space in grid control.


before:

col1 | col2 | col3 |
------+--------+-------+ -> user sizes form
| | |



after:

col1 | col2 | col3 |
-----------+--------+-------+
| | |



Administrator [Syncfusion]
Replied On December 11, 2008 12:29 PM UTC

I mean:

before:

__col1__|__col2__|__col3__|


after user changes the form:

________col1________|__col2__|__col3__|



Nisha Arockiya A [Syncfusion]
Replied On December 15, 2008 12:56 PM UTC

Hi

Thanks for being patience.

The GridControl.ColWidths.ResizeToFit method (or GridDataBoundGrid.Model.Colwidths.ResizeToFit) will resize a range of cells to fit.

To give an idea, inorder to resize the header is column 2, you would use something like

this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Cell(0,2));


To resize all of column 2, you would use something like

this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(2));


Please try and let me know any help you need.
Regards,
Nisha


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

;