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
close icon

Need to resize RowHeader column in grid when line number greater than 2 digits

I have a grid that has a RowHeader containing the line number which works fine, except when the line numbers get to 100 and above, they are truncated and the column cannot be manually resized.

I found 2-3 older threads on this forum about this issue, with various suggestions, none of which have worked for me so far.
Hopefully you can look into my attached examples and help me out.

The 'tuningGrid' is the grid with the problem.
There is a ResizeRowHeader() method which is trying to set the column resizing options; maybe it is in the wrong place.
I also have tried adding a tuningGrid_Loaded method where I set tuningGrid.Model.ColumnsWidths[0] = 300, but that crashes because ColumnWidths is empty at that point.

Attachment: RowHeader_4f17e17f.zip

2 Replies

AA Arulraj A Syncfusion Team January 21, 2019 10:36 AM UTC

 
Thanks for contacting Syncfusion support. 
 
To achieve your requirement “How to resize the row header based on the line numbers shown” using ResizeColumnsToFit method with GridResizeToFitOptions.NoShrinkSize as like the following code snippet 
 
void dataGrid_Loaded(object sender, RoutedEventArgs e) 
{ 
     this.dataGrid.Model.Grid.ScrollRows.Changed += ScrollRows_Changed; 
} 
 
 
private void ScrollRows_Changed(object sender, EventArgs e) 
{ 
     int lastrow = dataGrid.Model.Grid.ScrollRows.LastBodyVisibleLineIndex; 
     dataGrid.Model.ResizeColumnsToFit(GridRangeInfo.Cell(lastrow, 0), GridResizeToFitOptions.NoShrinkSize); 
} 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Arulraj A 



SM Steve McWilliams January 21, 2019 03:07 PM UTC

Thanks. That works now.

Loader.
Live Chat Icon For mobile
Up arrow icon