-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Hardeeks_it_matrix
Message 2 in Discussion




  
    
    New Message on MumbaiUserGroup
  
  





      .net 2.0 ... help me out.. its urgent..

    
  
    
      Reply

          
            
                
               
                  Reply to Sender
                    Recommend
                  
                  Message 1 in Discussion
                                                
            
          
        
                    
        
            
              From: 
              Hardeeks_it_matrix
            
            
              

              Dear friends,

In my current project I am using the CustomCollections with the help of 
BindingList<T> generic class to store the database records instead using 
DataSet objects as offline database identities.

Now I do have a large number of property classes each having a large number of 
properties in it.

I want to implement the INotifyPropertyChanged interface in every property 
class as follows:

The purpose to implement the INotifyPropertyChanged interface is I want to 
inform the UI whenever any property change occurs and update the it accodingly. 
Also I need to inform the ListChanged event of the my BindingList<T> collection 
object using the PropertyChangedEvent of INotifyPropertyChanged interface. I 
know that the PropertyChangedEvent automatically raises the ListChanged event 
of the BindingList<T> object.

I want to maintain a flag whose value will be false whenever the collection 
gets changed means any property value of any item in the collection gets 
changed.

My code is like below:


 public class Customer :INotifyPropertyChanged
    {
            
        private int number;
       
        public int Number
        {
            get { return number; }
            set { number = value;if(value!=number) OnPropertyChanged("Number"); 
}
        }

        private string name;

        public string Name
        {
            get { return name; }
            set { name = value;if(value != name) OnPropertyChanged("Name"); }
        }

  public event PropertyChangedEventHandler PropertyChanged;

        private void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new 
PropertyChangedEventArgs(propertyName));
        }
}

Now what if my class has 100 properties then....

Is there any way out so I dont need to write the same code like below again and 
again in each property's set method:

if(value != name) OnPropertyChanged("Name");

I dont want to write the above line for every property.

So is it possible to do this using Reflection and subscribe for the event 
PropertyChanged for every property in the class in a single code block..

I have seen such a code months ago on any website but can't recall it right now 
as that time I was not so serious and not knowing I might have to implement 
this in future:)

Suggest me how to do this and put the code snippet if possible.

THANKS in ADVANCE.

Regards,
Hardeek Thakkar
          
        
      
          
  

    View other groups in this category.
  

  

      




-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/mumbaiusergroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to