New to Telerik UI for WinFormsStart a free 30-day trial

Formatting Items

Updated over 6 months ago

Since RadFontDropDownList internally uses a RadListView in DetailsView, it is possible to customize each cell element, using the CellFormatting event.

You can access the hosted RadListView control by the RadFontDropDownList.FontListView property and subscribe to its CellFormatting event in order to customize cell elements:

WinForms RadFontDropDownList Formatting Items

Formatting the cell elements

C#
private void FontListView_CellFormatting(object sender, Telerik.WinControls.UI.ListViewCellFormattingEventArgs e)
{
    DetailListViewDataCellElement cell = e.CellElement as DetailListViewDataCellElement;
    if (cell == null)
    {
        return;
    }
    if (e.CellElement.Data.Name == "Preview" && e.CellElement.Text == "Aharoni")
    {
        e.CellElement.BackColor = Color.Yellow;
        e.CellElement.ForeColor = Color.Red;
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    }
    else if (cell.Row.Selected)
    {
        e.CellElement.BackColor = Color.Aqua;
        e.CellElement.ForeColor = Color.Black;
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}
Not finding the help you need?
Contact Support