2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
Display multi-line textBy default, the GridGroupingControl does not have direct support to ReSizeToFit the multi-line text. It can be displayed only by scrolling. Solution: To ReSizeToFit the multi-line text, a workaround solution in the QueryRowHeight event is available. In this event, the cell’s height has been calculated as per the current cell value along with the number of lines. C# //Event hooking in constructor. this.gridGroupingControl1.TableModel.QueryRowHeight += new GridRowColSizeEventHandler(TableModel_QueryRowHeight); //This event is triggered when the row height is changed. void TableModel_QueryRowHeight(object sender, GridRowColSizeEventArgs e) { if (e.Index > 0) { IGraphicsProvider graphicsProvider = this.gridGroupingControl1.TableModel.GetGraphicsProvider(); Graphics g = graphicsProvider.Graphics; GridStyleInfo style = this.gridGroupingControl1.TableModel[e.Index, 2]; GridCellModelBase model = style.CellModel; e.Size = model.CalculatePreferredCellSize(g, e.Index, 2, style, GridQueryBounds.Height).Height; e.Handled = true; } }
VB 'Event hooking. AddHandler gridGroupingControl1.TableModel.QueryRowHeight, AddressOf TableModel_QueryRowHeight 'This event gets triggered when the row height is changed. Private Sub TableModel_QueryRowHeight(ByVal sender As Object, ByVal e As GridRowColSizeEventArgs) If e.Index > 0 Then Dim graphicsProvider As IGraphicsProvider = Me.gridGroupingControl1.TableModel.GetGraphicsProvider() Dim g As Graphics = graphicsProvider.Graphics Dim style As GridStyleInfo = Me.gridGroupingControl1.TableModel(e.Index, 2) Dim model As GridCellModelBase = style.CellModel e.Size = model.CalculatePreferredCellSize(g, e.Index, 2, style, GridQueryBounds.Height).Height e.Handled = True End If End Sub
Note: Since, the height has been calculated in QueryRowHeight event that triggers frequently, the row height cannot be resized.
ScreenShot: Figure 1: Multi-line text ReSizedToFit Samples: |
2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.