質問

i have a Telerik GridView with a ComboBox Column, while filtering in this Combobox an appending list dropped down.

Same as the image below...

enter image description here

So i want to make the font of the Append list larger.

How to do it?

役に立ちましたか?

解決

RadDropDownList uses different popups for its default items representation and for its auto complete suggest items. Here is an example demonstrating how to change the font of both:

 void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
    {
        RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
        if (editor != null)
        {
            editor.DropDownStyle = RadDropDownStyle.DropDown;
            RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement;

            element.VisualItemFormatting -= element_VisualItemFormatting;
            element.AutoCompleteSuggest.DropDownList.VisualItemFormatting -= element_VisualItemFormatting;

            //this handles the default drop down formatting - when you press the arrow key to open the drop down
            element.VisualItemFormatting += element_VisualItemFormatting;
            //this handles the suggest popup formatting
            element.AutoCompleteSuggest.DropDownList.VisualItemFormatting += element_VisualItemFormatting;
        }
    }

    void element_VisualItemFormatting(object sender, VisualItemFormattingEventArgs args)
    {
        args.VisualItem.Font = new Font("Arial", 16);
    }

他のヒント

You could either make a CellTemplate with your font, or you could handle the CellFormating event and do something like this:

void radGridView_CellFormatting(object sender, CellFormattingEventArgs  e)      
{ 
    // For all cells under the Account Name column
    if(e.CellElement.ColumnInfo.Name == "Account Name")
    {
        if(e.CellElement.Value != null)
        {
            System.Drawing.Font newfontsize = new System.Drawing.Font(e.CellElement.Font.FontFamily.Name,20);

            for each(GridViewCellInfo cell in e.Row.Cells)
            {
                e.CellElement.Font = newfontsize;
            }

        }
    }
    // For all other cells under other columns
    else
    {
        e.CellElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.Font, Telerik.WinControls.ValueResetFlags.Local);
    }
}

Plug in whatever size font you want for the "newfontsize" variable. Also note that, the else statement may not be necessary in your case, but you can reset the font to default using the ResetValue property.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top