Declined
Last Updated: 31 May 2014 08:30 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 19 Aug 2013 10:38
Category:
Type: Bug Report
0
FIX - RadListView bound to a BindingList is not visually updated after changes in the BindingList
DECLINED: Data items must implement the INotifyPropertyChanged interface in order for the RadListView to be able to automatically reflect the changes. Here is how MyObject should be implemented:
    public class MyObject : INotifyPropertyChanged
    {
        private string name;

        public MyObject(string name)
        {
            this.name = name;
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
                if (this.PropertyChanged != null)
                {
                    this.PropertyChanged(this, new PropertyChangedEventArgs("Name"));
                }
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }





Reproduce:
-add a RadListView and bind it to a BindingList
-add a RadButton and implement its Click event to modify an item in the BindingList
The expected behaviour is to see the RadListView visually updated, but only DataSource collection is updated. Refreshing the RadListView does not help.

Workaround:
public partial class Form1 : Form
    {
        BindingList<MyObject> bindingList;

        public Form1()
        {
            InitializeComponent();

            bindingList = new BindingList<MyObject>();
            bindingList.Add(new MyObject("Item1"));
            bindingList.Add(new MyObject("Item2"));
            bindingList.Add(new MyObject("Item3"));
            bindingList.Add(new MyObject("Item4"));

            this.radListView1.DataSource = bindingList;
            this.radListView1.DisplayMember = "Name";
        }

        private void radButton1_Click(object sender, EventArgs e)
        {
            if (this.radListView1.SelectedItem != null)
            {
                bindingList[1].Name = "NewName";
                
                foreach (var item in this.radListView1.ListViewElement.ViewElement.Children[0].Children)
                {
                    ((SimpleListViewVisualItem)item).Synchronize();
                }
            }
        }
    }

    public class MyObject 
    {
        private string name;

        public MyObject(string name)
        {
            this.name = name;
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                this.name = value;
            }
        }
    }
1 comment
ADMIN
Ivan Todorov
Posted on: 31 May 2014 08:30
DECLINED: Data items must implement the INotifyPropertyChanged interface in order for the RadListView to be able to automatically reflect the changes.