Reset Data

Posted by: ramnath-fp on 8 September 2017, 2:23 pm EST

  • Posted 8 September 2017, 2:23 pm EST

    Hi,

    i have one class like this:-

    ///////////////////////////////////

    public class Ram

    {

      public string Name
            {
                get;
                set ;
            }

    }

     ///////////////////////////////////

     

    I am binding collection to spread.

    ////////////////////////////////////////

    BindingList  objectCollection=new BindingList ();

    Ram obj=New Ram();

    obj.Name="RAM NATH" ;

    objectCollection.Add(obj);

     ////////////////////////////////////////

    suppose on button click when i changed value of the object like this:-

    ///////////////////////////////

     objectCollection[0].Name="AMIT";

    ///////////////////////////////

    Note:-

     Data automatically not reset on spread.

    when i clicked on this cell or focus on this cell then data is  changed.

    I want to show current data automatically when we changed object value.

     

    please help me.

    thanks in advance.

    regards,

    Ram Nath Verma

    MUMBAI(INDIA)

     

  • Replied 8 September 2017, 2:23 pm EST

    Hello,


    You need to call ResetFocusRenderer() after changing the object's value which resets the focus renderer to its original state.


    Please have a look at the attached sample.


    Thanks.


    2010/07/ClassResetData.zip
  • Replied 8 September 2017, 2:23 pm EST

    Ram Nath Verma,


    In your example, neither the application nor the Ram object is providing notification to the list that the Ram object has changed.  Thus, the list never knows to provide notification to the spreadsheet that an item in the list has changed.  Thus, the spreadsheet never knows to repaint.


    One option is for the application to provide the notification via the ResetItem method on the list.  For example...


                objectCollection[0].Name = "AMIT";
                objectCollection.ResetItem(0);


    Another option is for the Ram object to provide notification via the INotifyPropertyChanged interface.  For example...


        public class Ram : INotifyPropertyChanged
        {
            private string name;
            public string Name
            {
                get
                {
                    return name;
                }
                set
                {
                    name = value;
                    NotifyPropertyChanged("Name");
                }
            }
            public event PropertyChangedEventHandler PropertyChanged;
            private void NotifyPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
        }

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels