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

How to set selected row hover over color

2 Answers 219 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
Iron
John asked on 28 Jan 2021, 02:59 PM
How do I change the back color of the select cell and hover over color in the dropdown?

2 Answers, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 01 Feb 2021, 06:09 PM

Hello, John,

In order to customize the cells in the grid within the MultiColumnComboBox, it is suitable to use the CellFormatting event. The following code snippet demonstrates how you can change the color of a selected cell:

public RadForm1()
{
    InitializeComponent();
    this.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.SelectionMode = GridViewSelectionMode.CellSelect;
    this.radMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CellFormatting += this.EditorControl_CellFormatting;
}

private void EditorControl_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.IsSelected)
    {
        e.CellElement.DrawFill = true;
        e.CellElement.BackColor = Color.Green;
        e.CellElement.NumberOfColors = 1;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.NumberOfColorsProperty);
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty);
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty);
    }
}

Similarly, you can change the color when the mouse hovers over cells. You can track which is the current hovered cell, for example in the MouseMove event, and apply the desired styling to this cell the CellFormatting event. Note, it is important to always reset the applied styles since the cells are reused.

I hope this helps. Should you have any other questions do not hesitate to contact me.

Regards,
Nadya
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/.

0
John
Top achievements
Rank 1
Iron
answered on 01 Feb 2021, 06:52 PM
Thanks you Nadya. Just what I was looking for.
Tags
MultiColumn ComboBox
Asked by
John
Top achievements
Rank 1
Iron
Answers by
Nadya | Tech Support Engineer
Telerik team
John
Top achievements
Rank 1
Iron
Share this question
or