This is a migrated thread and some comments may be shown as answers.

RadGridView- set font size for cell during edit

9 Answers 437 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Evan
Top achievements
Rank 1
Evan asked on 05 Aug 2018, 07:38 PM

Hello-  
I'm using a RadGridview (Telerik Winforms version 2018.1.220.40) and am having trouble setting the font size for a cell while it is being edited... I've managed to get everything else on my grid to Segoe 14pt, but when the user adds a new row, the cell they're typing in has a huge font that makes it unreadable.  When they tab to the next cell, it goes back to the standard font and the previous cell is readable, but the current cell again has a large font. 

Dess has helped me a couple times(thanks!), and I've looked for formatting event when cell edit starts, and googled, but can't find anything.    In short, would like for the font in a cell being edited to be the same as everything else on the grid...  

Thanks

9 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 06 Aug 2018, 12:55 PM
Hi Evan,

The formatting events are not suitable for this because they are not fired for the editor. The editor can be accessed in the CellEditorInitialized event. The following article shows how you can access all editors: Default Editors | RadGridView.

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Evan
Top achievements
Rank 1
answered on 06 Aug 2018, 02:27 PM

Thanks Dimitar- I'm able to use that event to set the font without error (CellEditorInitialized below), but my problem remains- the other columns are all legible and visible, but the one being edited only shows the upper part of the text being entered (presumably the font is still too big?) 

        Dim textboxEditor = TryCast(e.ActiveEditor, RadTextBoxEditor)
        If textboxEditor IsNot Nothing Then
            Dim element = TryCast(textboxEditor.EditorElement, RadTextBoxEditorElement)
            element.Font = f
        End If

0
Dimitar
Telerik team
answered on 07 Aug 2018, 06:23 AM
Hello Evan,

Could you please check if you are setting the font of the entire grid somewhere in your code and remove the setting or use a reasonable size.

Let me know how this works for you.

Regards,
Dimitar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Evan
Top achievements
Rank 1
answered on 08 Aug 2018, 05:21 PM

Hi Dimitar- I had actually set the font in the grid properties to Segoe UI, 14pt, and have tried setting the font in code as well.   Autosize rows has helped today, since the row now expands to show the letters.   It looks weird though, so I'd like to get it set.     

The only events I have coded are the form load, an unrelated button on the form, the Grid_FilterPopupInitialized, NodeFormatting, ViewCellFormatting and CellEditorInitialized.   The popinintialized, nodeformatting and ViewCellformatting events use a font declared at the class level:     Dim f As New Font("Segoe UI", 14, FontStyle.Regular) to set an element font. 

Any thoughts?   Thanks for looking at this... 

0
Dimitar
Telerik team
answered on 09 Aug 2018, 08:34 AM
Hi Evan,

14 is a big font size (the default is 8.25) and when using such size you will need to increase the rows height. One solution is to use the AutoSizeRows functionality. Another is to just set the following property:
radGridView1.TableElement.RowHeight = 35;
 
Please note that the editor is a bit bigger than the cell element and you need to consider this when setting the above property or consider using a smaller font only for the editor. 

Hope this is helpful.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Evan
Top achievements
Rank 1
answered on 13 Aug 2018, 05:11 PM

Thanks Dimitar- AutoRowSize helps, and I will look at setting the rowheight.  

You mention using a smaller font for the editor- can you tell me how to do that?   

Thanks,

 

0
Accepted
Dimitar
Telerik team
answered on 14 Aug 2018, 06:39 AM
Hi Evan,

I have tested this again and it appears that setting the font in the CellEditorInitialized event stops working after editing a few cells. In order this to work you need to set the font of the inner textbox. Here is the code:
Private f As New Font("Segoe UI", 10, FontStyle.Regular)
Private Sub RadGridView1_CellEditorInitialized(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs)
    Dim tbEditor As RadTextBoxEditor = TryCast(Me.radGridView1.ActiveEditor, RadTextBoxEditor)
    If tbEditor IsNot Nothing Then
        Dim tbElement As RadTextBoxEditorElement = CType(tbEditor.EditorElement, RadTextBoxEditorElement)
        tbElement.TextBoxItem.TextBoxControl.Font = f
    End If
End Sub

Let me know how this works for you.

Regards,
Dimitar
Progress Telerik
Get quickly onboard and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Evan
Top achievements
Rank 1
answered on 14 Aug 2018, 02:21 PM

That works great- (it does create a space between the row being edited and the next row during the edit- but I can live with that...) 

Thanks very much for all your time on this one. 

 

0
Hristo
Telerik team
answered on 15 Aug 2018, 09:30 AM
Hi Evan,

Indeed, having the editor with a decreased height may result in some empty space while editing. I am glad that the suggested approach would fit your actual setup. Yet, you can consider slightly decreasing the row height.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Evan
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Evan
Top achievements
Rank 1
Hristo
Telerik team
Share this question
or