Completed
Last Updated: 15 Aug 2017 08:13 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 04 Aug 2017 10:47
Category:
Type: Bug Report
1
FIX. RadListView - crash when binding RadListView to a collection of objects where the DisplayName attribute differs from field name
To reproduce:

public RadForm1()
{
    InitializeComponent();

    BindingList<Item> items = new BindingList<Item>();
    for (int i = 0; i < 10; i++)
    {
        items.Add(new Item(i,"Item" + i));
    }
    this.radListView1.DataSource = items;
    this.radListView1.ViewType = Telerik.WinControls.UI.ListViewType.DetailsView;
}

public class Item
{
    public int Id { get; set; }
    
   [DisplayName("MyName")]
    public string Name { get; set; }

    public Item(int id, string name)
    {
        this.Id = id;
        this.Name = name;
    }
}

Workaround: don't use the DisplayName attribute but change the column's header name in the ColumnCreating event:

private void radListView1_ColumnCreating(object sender, Telerik.WinControls.UI.ListViewColumnCreatingEventArgs e)
{
    if (e.Column.Name == "Name")
    {
        e.Column.HeaderText = "My Name";
    }
}
0 comments