Row Header Column Sizing

Hi,

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?

Thanks

Tristan.


1 Reply

KA Kamalakannan A Syncfusion Team January 18, 2011 05:28 PM UTC

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.

Thanks,
Kamal



Loader.
Up arrow icon