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

ListView - highlight column N

7 Answers 118 Views
ListView
This is a migrated thread and some comments may be shown as answers.
RTA
Top achievements
Rank 1
RTA asked on 07 Jul 2015, 08:32 PM

Hi, 

Is it possible to highlight an arbitrary column in a radListView?    I can't check for any particular data in the column header, all I know is that it will be column N.  I've seen discussions about how to highlight a row, but nothing on how to highlight a particular column. 

 Any suggestions would be appreciated. 

Steve

7 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 08 Jul 2015, 07:50 AM
Hello Steve,

Thank you for writing.

You will definitely need a way to identify the column you want to customize. If you know its index, this would be sufficient for the purpose. If not, when you add it, you can set its Tag or something, so you can later identify it. One you know the column you need to customize, the CellFormatting event is what you need:
void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
{
    if (radListView1.Columns.IndexOf(e.CellElement.Data) == 1 && e.CellElement is DetailListViewDataCellElement)
    {
        e.CellElement.BackColor = Color.Yellow;
        e.CellElement.GradientStyle = GradientStyles.Solid;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
    }
}

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
RTA
Top achievements
Rank 1
answered on 08 Jul 2015, 07:23 PM

Hi Stefan, 

 Thank for the code.  I knew it had to be in the cell formatting event, but wasn't sure how to test for the proper cells. 

From the attached pic, you can see that the bottom row is still highlighted.  Why is this happening?  I have no code to do that, so I'm guessing that it must be from a control property?  How do I effect the highlight of the bottom row? 

I tried a few things on the order of: 

 LVHistory.Items[LVHistory.Items.Count-1].BackColor= Color.White;

 but nothing seems to work. 

0
Stefan
Telerik team
answered on 10 Jul 2015, 01:49 PM
Hello Steve,

This is default control functionality and the styling comes from the theme - the currently selected row in the control gets highlighted. You can remove this highlighting by using the VisualItemFormatting event. In you can remove the cell border by setting the CellElement.DrawBorder property to false in the CellFormatting event:
void radListView1_VisualItemFormatting(object sender, ListViewVisualItemEventArgs e)
{
    e.VisualItem.DrawFill = false;
    e.VisualItem.DrawBorder = false;
}
 
void radListView1_CellFormatting(object sender, ListViewCellFormattingEventArgs e)
{
    e.CellElement.DrawBorder = false;
 
    if (radListView1.Columns.IndexOf(e.CellElement.Data) == 1 && e.CellElement is DetailListViewDataCellElement)
    {
        e.CellElement.BackColor = Color.Yellow;
        e.CellElement.GradientStyle = GradientStyles.Solid;
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
    }
}

I hope this helps.

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
RTA
Top achievements
Rank 1
answered on 10 Jul 2015, 04:13 PM

Stefan, 

 Thank you very much.  That was what I needed to know.

One final question for this thread... where can I find documentation describing which events get thrown by a control and when.    I assume such info is available and that I'm just looking in the wrong place. As an example to me, can you point me to a doc that described the answer you gave me? 

I appreciate all the great support Telerik provides, but if I can easily find these answers via the docs, that would save me time and lessen the load on Telerik support.

 Thanks,

Steve

0
Ralitsa
Telerik team
answered on 13 Jul 2015, 11:40 AM
Hi Steve,

Thank you for your reply. 

Currently you can refer to the online documentation for RadListView or you can follow the steps from Download Product Files article to see how to download the CHM, MS Help2 or MS Help3 documentation. 

I hope this will help. Do not hesitate to write back with further questions.

Regards,
Ralitsa
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
RTA
Top achievements
Rank 1
answered on 13 Jul 2015, 01:01 PM

Hi Ralitsa, 

Thanks for the links, but apparently I didn't state my question clearly.  I know where the online line help is and I use it often.  I was looking for a way to specifically find what each event for the control does and under what conditions that event is thrown without having to hunt  through detailed examples.  As the online help is structured, it doesn't easily provide this information.  Since you pointed me back to the general online help, I gather that the info I'm looking for doesn't readily exist.  That's ok. 

Thank you for your time.  Perhaps you can pass along the idea that providing a list such as I described could be helpful to some users. 

Steve

0
Accepted
Ralitsa
Telerik team
answered on 16 Jul 2015, 07:52 AM
Hi Steve,

The provided feedback how to improve our documentation is greatly appreciated. We try to include articles with descriptions of main properties, methods and events for most of our controls. We will consider improving the RadListView documentation in order to include the respective information accordingly.

Should you have further questions, I would be glad to help. 

Regards,
Ralitsa
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListView
Asked by
RTA
Top achievements
Rank 1
Answers by
Stefan
Telerik team
RTA
Top achievements
Rank 1
Ralitsa
Telerik team
Share this question
or