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
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
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
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
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...
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
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,
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
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.
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