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

Get RADListview Column header

1 Answer 319 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 09 Oct 2014, 05:30 AM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Oct 2014, 01:52 PM
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.

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