Checkbox Size
Hi, how can I change the size of a checkbox within the GridControl?
I'm adding the checkbox to a cell using:
GridControl1(2, 2).CellType = GridCellTypeName.CheckBox
I'm increasing the text size within the grid using:
GridControl1.BaseStylesMap("Standard").StyleInfo.Font.Size = 20
However, the checkbox size doesn't match the font size.
I have also tried changing the checkbox size using the following, but this doesn't work either:
Dim model1 As GridCheckBoxCellModel = TryCast(Me.GridControl1.Model.CellModels("CheckBox"), GridCheckBoxCellModel)
model1.ButtonBarSize = New Size(30, 30)
Kind Regards
Mike
SIGN IN To post a reply.
7 Replies
AR
Arulpriya Ramalingam
Syncfusion Team
April 10, 2017 06:14 AM UTC
Hi Mike,
Thanks for your interest in Syncfusion products.
The CheckBox size can be modified by creating a instance for the GridCheckBoxCellRenderer class and setting the size to CheckBoxSize property. Please make use of below code and sample,
Code snippet
|
'To set the CheckBox size
Dim renderer As GridCheckBoxCellRenderer = TryCast(Me.gridControl1.CellRenderers("CheckBox"), GridCheckBoxCellRenderer)
renderer.CheckBoxSize = New Size(30, 30) |
Screenshot
Regards,
Arulpriya
MN
mike newett
April 11, 2017 08:48 PM UTC
That worked perfectly, but has lead to another question.
How can I change the button size of the Month Calendar (the drop down button that opens the calendar)?
I am adding the calendar as follows:
GridControl1(5, 2).CellType = GridCellTypeName.MonthCalendar
Kind Regards
Mike
AR
Arulpriya Ramalingam
Syncfusion Team
April 12, 2017 08:38 AM UTC
Hi Mike,
Thanks for your update.
The DropDownButton size of the MonthCalendar cell can be modified by creating an instance for the GridDropDownMonthCalendarCellModel class and setting the size to ButtonBarSize property. Please make use of below code and sample,
Code snippet
|
'Creating instance for GridDropDowMonthCalendarCellModel
Dim model As GridDropDownMonthCalendarCellModel = TryCast(Me.gridControl1.CellModels("MonthCalendar"), GridDropDownMonthCalendarCellModel)
'Setting the size to Button
model.ButtonBarSize = New Size(30, 30) |
Note
The ButtonSize can be modified for any GridCellButton (i.e. ComboBox dropdownbutton, numericupdownbutton, etc.,) by creating the instance for corresponding CellModel as in sample. It is depending upon the corresponding cell’s CellModel
Regards,
Arulpriya
MN
mike newett
April 12, 2017 11:46 AM UTC
That worked perfectly, but has lead to another question again.
The drop down MonthCalendar font size and spacing between the dates needs to be bigger. It is difficult to use on a touch screen device.
How can this be done?
I am adding the monthcalendar as follows:
GridControl1(5, 2).CellType = GridCellTypeName.MonthCalendar
GridControl1(5, 2).CellValue = DateTime.Now
Kind Regards
Mike
AR
Arulpriya Ramalingam
Syncfusion Team
April 13, 2017 12:34 PM UTC
Hi Mike,
Thanks for your update.
The font size and space between dates of the DropDownMonthCalendar can be modified by using CurrentCellShowingDropDown event. In that event, the font for the DropDownContainerControl can be set by using control.Font property and the DropDownContainer size can be increased by using size property. Please make use of below code and sample,
Code snippet
|
Private renderer As GridDropDownMonthCalendarCellRenderer
renderer = TryCast(Me.gridControl1.CellRenderers("MonthCalendar"), GridDropDownMonthCalendarCellRenderer)
'Event Triggering
AddHandler gridControl1.CurrentCellShowingDropDown, AddressOf GridControl1_CurrentCellShowingDropDown
'Event Customization
Private Sub GridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs)
Dim currentCell As GridCurrentCell = Me.gridControl1.CurrentCell
If TypeOf currentCell.Renderer Is GridDropDownMonthCalendarCellRenderer Then
For Each control As Control In renderer.DropDownContainer.Controls
If control IsNot Nothing Then
control.Font = New Font("Segoe UI", 15f)
e.Size = New Size(310, 310)
End If
Next control
End If
End Sub |
Note
By default, MonthCalendar control does not have support to customize the font and its styles. To customize its appearance, Application.EnableVisualStyles() should not be used inside the Program.cs file. So please make sure that,
|
Namespace CellGrid_2008
Friend NotInheritable Class Program
Private Sub New()
End Sub
<STAThread> _
Shared Sub Main()
'Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
End Namespace |
Regards,
Arulpriya
MN
mike newett
May 2, 2017 03:47 AM UTC
Hi Arulpriya,
That works brilliantly.
However, is there a way to set the dropdown calendar size automatically to allow for different font sizes and DPI settings?
I have tried calculating the height and width, but it doesn't work well. I assume there's some way of getting the bounds of the internal controls to set the size?
Finally, is it possible to change the visual style of the calendar to make it look the same as it was before visual styles were disabled?
My modified code is below:
'Set calendar font size
Private Sub GridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs)
Dim currentCell As GridCurrentCell = GridControl1.CurrentCell
If TypeOf currentCell.Renderer Is GridDropDownMonthCalendarCellRenderer Then
For Each control As Control In MonthCalendarRenderer.DropDownContainer.Controls
If control IsNot Nothing Then
Private Sub GridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs)
Dim currentCell As GridCurrentCell = GridControl1.CurrentCell
If TypeOf currentCell.Renderer Is GridDropDownMonthCalendarCellRenderer Then
For Each control As Control In MonthCalendarRenderer.DropDownContainer.Controls
If control IsNot Nothing Then
Dim FontSize As Integer = GridControl1.BaseStylesMap("Standard").StyleInfo.Font.Size
Dim CalendarHeight As Integer = 200 * (FontSize / 10)
Dim CalendarWidth As Integer = 210 * (FontSize / 10)
control.Font = New Font("Segoe UI", FontSize)
e.Size = New Size(CalendarWidth, CalendarHeight)
Dim CalendarHeight As Integer = 200 * (FontSize / 10)
Dim CalendarWidth As Integer = 210 * (FontSize / 10)
control.Font = New Font("Segoe UI", FontSize)
e.Size = New Size(CalendarWidth, CalendarHeight)
MonthCalendarRenderer.DropDownContainer.BorderStyle = BorderStyle.FixedSingle
End If
Next control
End If
End Sub
End If
Next control
End If
End Sub
Kind Regards
Mike
AR
Arulpriya Ramalingam
Syncfusion Team
May 3, 2017 08:58 AM UTC
Hi Mike,
Thanks for your update.
|
Query |
Response |
|
is there a way to set the dropdown calendar size automatically to allow for different font sizes and DPI settings?
I have tried calculating the height and width, but it doesn't work well. I assume there's some way of getting the bounds of the internal controls to set the size?
|
By default the DropDownContainer size will not be changed based on DPI. In order to change the DropDownContainer size automatically for different DPI CurrentCellShowingDropDown event can be customized. In that event, Size property can be used to set the size for the drop down control based on DPI. Please make use of below code and sample,
Dim defaultDPI As Single = 96 'default dpi for 100DPI
Dim currentDPI As Single
Using g As Graphics = Me.CreateGraphics()
currentDPI = g.DpiX
If currentDPI <> defaultDPI Then
'To get the scalefactor for different DPI
scalefactor = currentDPI / defaultDPI
End If
End Using
'Event Triggering
AddHandler gridControl1.CurrentCellShowingDropDown, AddressOf GridControl1_CurrentCellShowingDropDown
'Event Customization
Private Sub GridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs)
Dim currentCell As GridCurrentCell = Me.gridControl1.CurrentCell
If TypeOf currentCell.Renderer Is GridDropDownMonthCalendarCellRenderer Then
For Each control As Control In renderer.DropDownContainer.Controls
If control IsNot Nothing Then
Dim fontSize As Single = gridControl1.BaseStylesMap("Standard").StyleInfo.Font.Size
control.Font = New Font("Segoe UI",(fontSize*scalefactor))
Dim width As Single = (e.Size.Width * scalefactor)
Dim height As Single = (e.Size.Height * scalefactor)
'To set the size for DropDown container based on DPI.
e.Size = New Size(CInt(Fix(width)), CInt(Fix(height)))
End If
Next control
End If
End Sub
|
|
is it possible to change the visual style of the calendar to make it look the same as it was before visual styles were disabled? |
Yes, the VisualStyle of the calendar can be changed as same as before by enabling the Application.EnableVisualStyles() inside of the program.cs file. Please refer the below code,
Namespace CellGrid_2008
Friend NotInheritable Class Program
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Public Shared Function SetProcessDPIAware() As IntPtr
End Function
Private Sub New()
End Sub
<STAThread> _
Shared Sub Main()
SetProcessDPIAware()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(False)
Application.Run(New Form1())
End Sub
End Class
End Namespace
Note:
If you include the EnableVisualStyles in program.cs , the appearance customization(calendar size and font size, etc)of the MonthCalendar will not be worked.
Please let us know if we misunderstood anything. |
Please let us know if you need any further assistance.
Regards,
Arulpriya
SIGN IN To post a reply.
- 7 Replies
- 2 Participants
-
MN mike newett
- Apr 7, 2017 06:56 PM UTC
- May 3, 2017 08:58 AM UTC