The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
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
End If
End Sub
''===================================
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 05:47 PM UTC
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 06:44 PM UTC
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
gridControl1.Model.ColWidths.SetSize(1, cw)
gridControl1.Model.RowHeights.ResizeToFit(GridRangeInfo.Col(1))
gridControl1.Refresh()
''gridControl1.Model.ColWidths.ResizeToFit(GridRangeInfo.Col(1))
End Sub