Get RADListview Column header

2 posts, 1 answers
  1. Ricardo
    Ricardo avatar
    1 posts
    Member since:
    Oct 2014

    Posted 09 Oct 2014 Link to this post

    Hi:

    Does anybody knows How to get in a RadListView all the column headers name?

    I need to populate a listbox with them?

    Any suggestions?

    Thanks.
  2. Answer
    Dess
    Admin
    Dess avatar
    1609 posts

    Posted 13 Oct 2014 Link to this post

    Hello Ricardo,

    Thank you for writing.

    RadListView.Columns collection contains the respective columns. You can iterate through the collection and access the ListViewDetailColumn.HeaderText property:
    public Form1()
    {
        InitializeComponent();
        List<Item> items = new List<Item>();
        for (int i = 0; i < 5; i++)
        {
            items.Add(new  Item(i,"Item"+i, DateTime.Now.AddDays(i)));
        }
     
        this.radListView1.DataSource = items;
        this.radListView1.ViewType = ListViewType.DetailsView;
        foreach (ListViewDetailColumn column in this.radListView1.Columns)
        {
            Console.WriteLine(column.HeaderText);
        }
       
    }
     
    public class Item
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public DateTime CreatedOn { get; set; }
        public Item(int id, string name, DateTime createdOn)
        {
            this.Id = id;
            this.Name = name;
            this.CreatedOn = createdOn;
        }
    }

    More information and example is available in the Adding columns section of the following article: http://www.telerik.com/help/winforms/listview-programatically-populating-with-data.html.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top