Hopefully someone will be able to help...I''ve been banging my head against the wall over this for awhile.
I have a grid in which has 1 data column, where the column is stretched to fill the client window size using the following code:
Private Sub GridControl1_QueryColWidth(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs) Handles gridControl1.QueryColWidth
If e.Index = gridControl1.ColCount Then
Dim width As Integer = IIf(gridControl1.ColCount <= 0, 0, gridControl1.ColWidths.GetTotal(0, gridControl1.ColCount - 1))
e.Size = gridControl1.ClientRectangle.Width - width
e.Handled = True
This works fine...however some of the data cells contain a lot of data, and after a client resize, I would also like the height of the cell to grow/shrink to better fit the data. When I include the obvious solution "grid.model.rowheight.resizeTofit"...I get a stack overflow exception. I''ve realized this is because resizeToFit recursively calls queryColumnWidth, so were stuck in an endless loop. Is there any better way to get the preffered column height without calling ResizeToFit?
ADAdministrator Syncfusion Team July 26, 2005 12:47 PM
If you only want to call ResizeToFit when the client gets resized, then try calling it from the grid.SizedChanged event to see if that will work for you.
ADAdministrator Syncfusion Team July 26, 2005 01:44 PM
Perfect...thanks for the tip!
if anyone else is interested, this code works:
Private Sub gridControl1_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gridControl1.SizeChanged
Dim cw As Integer = gridControl1.ColWidths.GetTotal(0, gridControl1.ColCount - 1)
cw = gridControl1.ClientRectangle.Width - cw