hi
i can change font FilterPopup but font "available filers" not changes
This section is marked in the photo below
9 Answers, 1 is accepted
Hello, Мoj,
I have prepared a sample code snippet demonstrating how to change the font for the menu items in the Excel-like filter popup:
public RadForm1()
{
InitializeComponent();
this.radGridView1.EnableFiltering = true;
this.radGridView1.ShowHeaderCellButtons = true;
this.radGridView1.FilterPopupInitialized+=radGridView1_FilterPopupInitialized;
}
Font f = new Font("Arial", 12f, FontStyle.Italic );
private void radGridView1_FilterPopupInitialized(object sender, FilterPopupInitializedEventArgs e)
{
RadListFilterPopup popup = e.FilterPopup as RadListFilterPopup;
if (popup!=null)
{
popup.Font = f;
foreach (RadItem item in popup.Items)
{
item.Font = f;
RadMenuItem menuItem= item as RadMenuItem;
if (menuItem!=null && menuItem.Items.Count>0)
{
foreach (RadItem childItem in menuItem.Items)
{
childItem.Font = f;
}
}
}
popup.MenuTreeElement.TreeView.NodeFormatting-=TreeView_NodeFormatting;
popup.MenuTreeElement.TreeView.NodeFormatting+=TreeView_NodeFormatting;
}
}
private void TreeView_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
{
e.NodeElement.Font = f;
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
hello Dess
very thanks
I also want to change the font of the "filter dialog"
According to the provided screenshots, it seems that you want to customize the composite filter dialog. Note that you have access to the dialog via the RadGridView.CreateCompositeFilterDialog event. You can change the font for the dialog as it is demonstrated in the following article: https://docs.telerik.com/devtools/winforms/controls/gridview/filtering/custom-filter-dialog
It is possible to iterate the dialog's Controls collection and set the Font for each contained control explicitly. Since the CompositeDataFilterForm internally uses a RadTreeView, the appropriate way to change the font is by handling the NodeFormatting event: https://docs.telerik.com/devtools/winforms/controls/datafilter/customizing-appearance/formatting-nodes
private void RadGridView1_CreateCompositeFilterDialog(object sender, GridViewCreateCompositeFilterDialogEventArgs e)
{
CompositeDataFilterForm form = e.Dialog as CompositeDataFilterForm;
if (form!=null)
{
form.Font = f;
ChangeFont(form.Controls);
form.DataFilter.NodeFormatting -= DataFilter_NodeFormatting;
form.DataFilter.NodeFormatting += DataFilter_NodeFormatting;
form.DataFilter.EditorInitialized -= DataFilter_EditorInitialized;
form.DataFilter.EditorInitialized += DataFilter_EditorInitialized;
}
}
private void ChangeFont(Control.ControlCollection controls)
{
foreach (Control c in controls)
{
c.Font = f;
if (c.Controls.Count>0)
{
ChangeFont(c.Controls);
}
}
}
private void DataFilter_EditorInitialized(object sender, TreeNodeEditorInitializedEventArgs e)
{
TreeViewDropDownListEditor dropDownEditor = e.Editor as TreeViewDropDownListEditor;
if (dropDownEditor!=null)
{
BaseDropDownListEditorElement el = dropDownEditor.EditorElement as BaseDropDownListEditorElement;
el.Font = f;
el.VisualItemFormatting -= El_VisualItemFormatting;
el.VisualItemFormatting += El_VisualItemFormatting;
}
}
private void El_VisualItemFormatting(object sender, VisualItemFormattingEventArgs args)
{
args.VisualItem.Font = f;
}
private void DataFilter_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
{
DataFilterCriteriaElement dataExpressionFilterElement = e.NodeElement as DataFilterCriteriaElement;
if (dataExpressionFilterElement!=null)
{
dataExpressionFilterElement.FieldElement.Font = f;
dataExpressionFilterElement.OperatorElement.Font = f;
dataExpressionFilterElement.ValueElement.Font = f;
}
e.NodeElement.Font = f;
}
Font f = new Font("Arial", 12f, FontStyle.Italic );
In the CreateCompositeFilterDialog event you can also set the CompositeDataFilterForm.RightToLeft property to Yes.
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
hi
very thanks
this done
but font item in RadDropDownButton not change
Hello, Мoj,
Please refer to the following modified code snippet demonstrating how to change the font for the drop down items:
private void DataFilter_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
{
DataFilterCriteriaElement dataExpressionFilterElement = e.NodeElement as DataFilterCriteriaElement;
if (dataExpressionFilterElement!=null)
{
dataExpressionFilterElement.FieldElement.Font = f;
dataExpressionFilterElement.OperatorElement.Font = f;
dataExpressionFilterElement.ValueElement.Font = f;
}
DataFilterAddNodeElement addNodeElement = e.NodeElement as DataFilterAddNodeElement;
if (addNodeElement !=null)
{
foreach (RadItem item in addNodeElement.DropDownButton.Items)
{
item.Font = f;
}
}
e.NodeElement.Font = f;
}
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
hi
very thanks
Sorry for the many questions
The font of the following items has not changed either
The provided screenshots illustrate the Conditional formatting dialog and the context menu for the header cells. You can handle the ContextMenuOpening and the ConditionalFormattingFormShown event and change the font for the menu items and the nested controls in the dialog:
this.radGridView1.ContextMenuOpening += RadGridView1_ContextMenuOpening;
private void RadGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
if (e.ContextMenuProvider is GridHeaderCellElement)
{
foreach (RadItem item in e.ContextMenu.Items)
{
item.Font = f;
}
}
}
this.radGridView1.ConditionalFormattingFormShown += RadGridView1_ConditionalFormattingFormShown;
private void RadGridView1_ConditionalFormattingFormShown(object sender, EventArgs e)
{
ConditionalFormattingForm form = sender as ConditionalFormattingForm;
form.Font = f;
ChangeFont(form.Controls);
}
private void ChangeFont(Control.ControlCollection controls)
{
foreach (Control c in controls)
{
c.Font = f;
if (c.Controls.Count > 0)
{
ChangeFont(c.Controls);
}
}
}
Note that this is just a sample approach and it may not cover all possible cases. Feel free to modify and extend it in a way which suits your requirements best.
If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
hello
very very thanks