change the highlight color of selected row in the RadListView

1 Answer 196 Views
ListView
Wenyu
Top achievements
Rank 1
Wenyu asked on 28 Apr 2023, 04:57 AM

I want to change the highlight color of a selected row. But, I can't. 

Could you tell me how to do it?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 01 May 2023, 02:04 PM

Hi, Wenyu,

According to the provided screenshot, it seems that you are using ListViewType.DetailsView. In order to change the color for the selected cells, it is suitable to subscribe to the CellFormatting event and customize the color: 

        private void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
        {
            DetailListViewDataCellElement cell = e.CellElement as DetailListViewDataCellElement;
            if (cell != null && cell.Row.Selected)
            {
                e.CellElement.ForeColor = Color.Black;
                e.CellElement.BackColor = Color.Yellow;
                e.CellElement.DrawFill = true;
                e.CellElement.GradientStyle = GradientStyles.Solid;
            }
            else
            { 
                e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
                e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
                 e.CellElement.ResetValue(LightVisualElement.ForeColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ListView
Asked by
Wenyu
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or