Hello SyncFusion!
I have a GridGroupingControl and some of the colums have very little information in the cells, but the header is much longer.
When a user doubleclick the "space" between two colums to automatic change the size, the colum will resize based on the width of the infromation in the cell.
I would like to have it use the max between the header and the information in the cell.
I tried to make something like this myself, but there are some problems, here is the rough code, I'll go over the problems after.
AddHandler myGrid.TableControlResizingColumns, AddressOf Grid_TableControlResizingColumns
myGrid.AllowProportionalColumnSizing = True
Private Sub Grid_TableControlResizingColumns(sender As Object, e As GridTableControlResizingColumnsEventArgs)
If (e.Inner.Reason = GridResizeCellsReason.DoubleClick) Then
Dim field = e.TableControl.Table.TableDescriptor.ColIndexToField(e.Inner.Columns.Right)
Dim headerLength = e.TableControl.Table.TableDescriptor.Columns(field).HeaderText.Length
Dim minLength = Int32.Parse(IIf(headerLength * 10 > 100, headerLength * 10, 100).ToString())
e.TableControl.Table.TableDescriptor.Columns(field).ResetWidth()
e.TableControl.Table.TableDescriptor.Columns(field).Width = minLength
e.TableControl.Refresh()
e.TableControl.Table.Reload()
e.Inner.Cancel = True
End If
End Sub
So my plan here is to try and make some rough minimumsize for the colums, by taking the amout of characters in the headers and taking that times 10, but if the name of the header is very small, then it will still look strange, so I also have a minimum of 100 (this is just a arbitary number and could easy be changed).
But the long story short is that this simply doesn't work, I still have colums that become the very small size that is the size of the information in the cell.
Am I missing something?
The event is hit, I can see that the width is changed, and then after that I both refresh and reload the grid.
I've also tried some small adjustments such as removing the AllowProportionalColumnSizing = True, or not having refresh/reload/cancel, nothing of this works, I've also tried not to reset the width first, and I've tried using the SetWidthInt() instead of just seting Width. None of this changes have done anything.