更改Telerik GricViewComboBox附加列表字体

时间:2013-01-14 13:53:51

标签: c# winforms telerik radgridview datagridviewcombobox

我有一个带有ComboBox列的Telerik GridView,而在此Combobox中过滤掉了一个附加列表。

与下图相同......

enter image description here

所以我想让Append列表的字体更大。

怎么做?

2 个答案:

答案 0 :(得分:2)

RadDropDownList为其默认项目表示及其自动完成建议项目使用不同的弹出窗口。这是一个演示如何更改两者字体的示例:

 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);
    }

答案 1 :(得分:0)

您可以使用您的字体制作CellTemplate,也可以处理CellFormating事件并执行以下操作:

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);
    }
}

为“newfontsize”变量插入所需大小的字体。另请注意,在您的情况下可能不需要else语句,但您可以使用ResetValue属性将字体重置为默认值。

相关问题