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.

Row Header Column Sizing

Thread ID:





97820 Jan 11,2011 01:51 PM Jan 18,2011 12:28 PM WPF 1
Tags: GridControl
Administrator [Syncfusion]
Asked On January 11, 2011 01:51 PM


I have the following code to add line numbers to my grid:

private void myGrid_ModelQueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
// Place a nice row number on each grid row
if (e.Cell.ColumnIndex == 0 && e.Cell.RowIndex != 0 && e.Cell.RowIndex != (myGrid.Model.RowCount - 1))
e.Style.CellValue = e.Cell.RowIndex;

This works fine in terms of displying the correct row number but when I get to large line numbers, the header row does not increase in width to accomodate the line number.

Is there any property I can set to autosize the row header column or if not any code I can write to do this?



Kamalakannan A [Syncfusion]
Replied On January 18, 2011 12:28 PM

Hi Tristan,

Thanks for using syncfusion products.

In WPF GridDataControl, You can Resize Row Header Size Automatically based on the RowIndex by invoking the ResizeColumnsToFit method by passing the GridResizeToFitOptions as NoShrinkSize, as shown in the following code snippet.

Code Snippet[C#]

this.grid.ModelLoaded += new EventHandler(grid_ModelLoaded);

void grid_ModelLoaded(object sender, EventArgs e)
this.grid.Model.ResizeColumnsToFit(GridRangeInfo.Col(0), GridResizeToFitOptions.NoShrinkSize);

Please download the workaround sample from the below location and check it out.

Sample link:< http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=ObservableCollection-1701379591.zip >

Please let us know if you need more information.



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.