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

GridView Filter Row Font Size

3 Answers 346 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lu Pazmino
Top achievements
Rank 1
Lu Pazmino asked on 12 Nov 2009, 09:39 PM
Hello,

I have a winform GridView that I'm having a hard time changing the font size. Here is my code.

        private void radGridView1_ViewCellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
        {
            Font font = new Font("Arial", 20f);
            if (e.CellElement is Telerik.WinControls.UI.GridFilterCellElement)
            {
                ((Telerik.WinControls.UI.GridViewFilteringRowInfo)e.CellElement.RowInfo).Height = 40;               
                e.CellElement.DrawFill = true;
                e.CellElement.NumberOfColors = 1;
                e.CellElement.BackColor = Color.Beige;
                e.CellElement.Font = font;
            }

I have also attached a screen-shot of my issue. Basically this changes the font size of the filter row, when the user is not in a cell typing something. But when I try to filter a column and set focus to that specific filter cell, i get a textbox in front of the "big" text with the normal 8.25 point font. What am I doing wrong?

Thanks,
Lu



3 Answers, 1 is accepted

Sort by
0
Lu Pazmino
Top achievements
Rank 1
answered on 17 Nov 2009, 11:26 PM
Isn't  there anyone that can help with this??????
0
Accepted
Martin Vasilev
Telerik team
answered on 18 Nov 2009, 12:41 PM
Hello Lu Pazmino,

Thank you for the question.

When you enter the filter cell element you actually initialize the respective editor which comes with its own font settings. That is why you have experience described behavior. You can change the editors' font in the CellBeginEdit event. For performance optimizations, I recommend you to initialize the new font outside the ViewCellFormatting event. Please, consider the following code:
Font filterRowFont = new Font("Arial", 20f);
 
void radGridView1_CellBeginEdit(object sender, GridViewCellCancelEventArgs e)
{
    if (this.radGridView1.CurrentRow is GridViewFilteringRowInfo)
    {
        BaseGridEditor editor = this.radGridView1.ActiveEditor as BaseGridEditor;
        if (editor == null) return;
        Type elementType = editor.EditorElement.GetType();
 
        switch (elementType.Name)
        {
            case "RadTextBoxEditorElement":
                ((RadTextBoxEditorElement)editor.EditorElement).Font = this.filterRowFont;
                break;
 
            case "RadMaskedEditBoxItem":
                ((RadMaskedEditBoxItem)editor.EditorElement).Font = this.filterRowFont;
                break;
 
            case "GridSpinEditorElement":
                ((GridSpinEditorElement)editor.EditorElement).TextBoxItem.Font = this.filterRowFont;
                break;
 
            case "RadComboBoxEditorElement":
                ((RadComboBoxEditorElement)editor.EditorElement).TextBoxElement.TextBoxItem.Font = this.filterRowFont;
                break;
 
            case "RadDateTimeEditorElement":
                ((RadDateTimeEditorElement)editor.EditorElement).TextBoxElement.TextBoxItem.Font = this.filterRowFont;
                break;
        }
    }
}
 
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    //Font font = new Font("Arial", 20f);
    if (e.CellElement is Telerik.WinControls.UI.GridFilterCellElement)
    {
        ((Telerik.WinControls.UI.GridViewFilteringRowInfo)e.CellElement.RowInfo).Height = 40;
        e.CellElement.DrawFill = true;
        e.CellElement.NumberOfColors = 1;
        e.CellElement.BackColor = Color.Beige;
        e.CellElement.Font = this.filterRowFont; //font;
    }
}

Do not hesitate to contact me again if you have other questions.

Kind regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Lu Pazmino
Top achievements
Rank 1
answered on 18 Nov 2009, 06:47 PM
Thanks so much Martin. That was exactly what I needed. I really appreciate your help.
Tags
GridView
Asked by
Lu Pazmino
Top achievements
Rank 1
Answers by
Lu Pazmino
Top achievements
Rank 1
Martin Vasilev
Telerik team
Share this question
or