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

Row Header Column Sizing

Thread ID:

Created:

Updated:

Platform:

Replies:

97820 Jan 11,2011 06:51 PM UTC Jan 18,2011 05:28 PM UTC WPF 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On January 11, 2011 06:51 PM UTC

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.


Kamalakannan A [Syncfusion]
Replied On 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



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

;