2X faster development
The ultimate WinForms UI toolkit to boost your development speed.
By default, the checkboxsize will not be changed based on current DPI. So, checkbox will be drawn with the default size in all DPI. In order to change the CheckBox size based on the current DPI, the CheckboxSize property of GridCheckBoxCellRenderer class can be used. Code Snippet C# //To change the CheckBox size based on DPI. GridCheckBoxCellRenderer renderer = this.gridControl1.CellRenderers["CheckBox"] as GridCheckBoxCellRenderer; System.Drawing.Size checkboxSize = renderer.CheckBoxSize; //Default DPI float defaultDpi = 96; float currentDpi; using (Graphics g = this.CreateGraphics()) { currentDpi = g.DpiX; if (currentDpi != defaultDpi) { float scalefactor = currentDpi / defaultDpi; renderer.CheckBoxSize = new Size((int)(scalefactor * checkboxSize.Width), (int)(scalefactor * checkboxSize.Height)); } }
VB 'To change the CheckBox size based on DPI. Dim renderer As GridCheckBoxCellRenderer = TryCast(Me.gridControl1.CellRenderers("CheckBox"), GridCheckBoxCellRenderer) Dim checkboxSize As System.Drawing.Size = renderer.CheckBoxSize 'Default DPI Dim defaultDpi As Single = 96 Dim currentDpi As Single Using g As Graphics = Me.CreateGraphics() currentDpi = g.DpiX If currentDpi <> defaultDpi Then Dim scalefactor As Single = currentDpi / defaultDpi renderer.CheckBoxSize = New Size(CInt(Fix(scalefactor * checkboxSize.Width)), CInt(Fix(scalefactor * checkboxSize.Height))) End If End Using
Screenshot
Note: The CheckBoxsize can also be changed in GridGroupingControl for current DPI as the same way.
Getting the GridCheckBoxCellRenderer C# GridCheckBoxCellRenderer renderer = this.gridGroupingControl1.TableControl.CellRenderers["CheckBox"] as GridCheckBoxCellRenderer;
VB Dim renderer As GridCheckBoxCellRenderer = TryCast(Me.gridGroupingControl1.TableControl.CellRenderers("CheckBox"), GridCheckBoxCellRenderer)
Sample Link: C#: CheckBoxSize_CS VB: CheckBoxSize_VB |
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.