ListView - highlight column N

8 posts, 1 answers
  1. Steve
    Steve avatar
    11 posts
    Member since:
    Jul 2012

    Posted 07 Jul 2015 Link to this post

    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

  2. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 08 Jul 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Steve
    Steve avatar
    11 posts
    Member since:
    Jul 2012

    Posted 08 Jul 2015 in reply to Stefan Link to this post

    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. 

  5. Stefan
    Admin
    Stefan avatar
    2890 posts

    Posted 10 Jul 2015 Link to this post

    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 addition 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
  6. Steve
    Steve avatar
    11 posts
    Member since:
    Jul 2012

    Posted 10 Jul 2015 in reply to Stefan Link to this post

    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

  7. Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 13 Jul 2015 Link to this post

    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
  8. Steve
    Steve avatar
    11 posts
    Member since:
    Jul 2012

    Posted 13 Jul 2015 in reply to Ralitsa Link to this post

    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

  9. Answer
    Ralitsa
    Admin
    Ralitsa avatar
    176 posts

    Posted 16 Jul 2015 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready