Category / Section
How to increase the row height according to the font size?
1 min read
To increase the row height of the cell, based on the font size by using ResizeToFitOptimized property. To set the font size of the cell by using following ways,
Way1: BaseStylesMap
Way2: PrepareViewStyleInfo
Way1
C#:
this.gridDataBoundGrid1.BaseStylesMap.Standard.StyleInfo.Font.Size=25;
VB:
Me.gridDataBoundGrid1.BaseStylesMap.Standard.StyleInfo.Font.Size=25
Way2
C#:
this.gridDataBoundGrid1.PrepareViewStyleInfo += new GridPrepareViewStyleInfoEventHandler(gridDataBoundGrid1_PrepareViewStyleInfo); } private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if (e.RowIndex >= 0 && e.ColIndex > 0) { e.Style.Font.Size = 20; } }
VB
Private Me.gridDataBoundGrid1.PrepareViewStyleInfo += New GridPrepareViewStyleInfoEventHandler(AddressOf gridDataBoundGrid1_PrepareViewStyleInfo) } Private Sub gridDataBoundGrid1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs) If e.RowIndex >= 0 AndAlso e.ColIndex > 0 Then e.Style.Font.Size = 20 End If End Sub
ResizeToFitOptimized property helps to increase the heights of the row based on the font size.
C#:
this.gridDataBoundGrid1.Model.RowHeights.ResizeToFitOptimized(GridRangeInfo.Table());
VB:
Me.gridDataBoundGrid1.Model.RowHeights.ResizeToFitOptimized(GridRangeInfo.Table())
Sample
C#: Row height
VB: Row height