Click here to Skip to main content
15,888,253 members
Home / Discussions / C#
   

C#

 
AnswerRe: Expression to Check for a String Value in All Properties of a Type Pin
Eddy Vluggen28-Oct-14 9:09
professionalEddy Vluggen28-Oct-14 9:09 
GeneralRe: Expression to Check for a String Value in All Properties of a Type Pin
Agent__00728-Oct-14 17:24
professionalAgent__00728-Oct-14 17:24 
GeneralRe: Expression to Check for a String Value in All Properties of a Type Pin
Eddy Vluggen29-Oct-14 8:57
professionalEddy Vluggen29-Oct-14 8:57 
AnswerRe: Expression to Check for a String Value in All Properties of a Type Pin
Alaric_28-Oct-14 10:22
professionalAlaric_28-Oct-14 10:22 
GeneralRe: Expression to Check for a String Value in All Properties of a Type Pin
Agent__00728-Oct-14 17:26
professionalAgent__00728-Oct-14 17:26 
AnswerRe: How I Got it (Partially) Done Pin
Agent__00728-Oct-14 17:08
professionalAgent__00728-Oct-14 17:08 
Questioninherit a observablecollection Pin
cicill27-Oct-14 0:39
cicill27-Oct-14 0:39 
AnswerRe: inherit a observablecollection Pin
BillWoodruff27-Oct-14 1:50
professionalBillWoodruff27-Oct-14 1:50 
Edit #1: I wonder if what you are really after is a way to encapsulate PropertyChanged Events within an ObservableCollection: so that you could assign one Delegate to the ObservableCollection that would route all PropertyChanged notifications to one EventHandler you defined ? 
I can't say I understand your code, since it is not clear to me what your goal is in mixing and matching ObservableCollection and INotifyPropertyChanged: note you never implement a CollectionChanged Event. And, you have another ObservableCollection, 'Grades, inside your 'Student Class which promises to implement INotifyPropertyChanged.

I strongly suggest you study implementing INotifyPropertyChanged first, and, when you understand it, move on to using ObservableCollection. When you know how to use both, then make a list of exactly what events you wish to be notified of ... which notifications you want to use from the ObservableCollection (Add, Remove, Move, Replace, Reset). Of course, INotifyPropertyChanged even handling is only going to give you one thing: the PropertyName (string) of the changed Property.

But, I can try to help you understand inheriting from ObservableCollection to some degree (I hope):

There should be a "good reason" to inherit from something like ObservableCollection<T>: "good reasons" are usually because:

1. you need to extend the inherited-from object: i.e., add functionality

2. you want to over-ride behavior (methods) in the inherited-from object.

Assume I have a class 'Student which has a constructor like this: note that only one parameter is required to be specified to create a new instance:
public Student(DateTime admissionDate, string stuName = "", string stuClass = "", string stuAddress = "")
{
   AdmissionDate = admissionDate;
   StuName = stuName;
   StuClass = stuClass;
   StuAddress = stuAddress;
}
If I inherit from ObservableCollection<Student> and extend it by adding my own 'Add method:
C#
public class Students : ObservableCollection<Student>
{
    internal void Add(string admDate, string name)
    {
        base.Add(new Student(Convert.ToDateTime(admDate), name));
    }
}
I can enable easy in-line syntax entry of new Items in the ObservableCollection:
C#
Students StudentsCollection = new Students
{
    {"02/05/2012", "Moe"},
    {"11/05/2013", "Curly"},
    {"02/05/2014", "Larry"},
    {"01/05/2010", "Mutt"},
    {"02/05/2010", "Jeff"},
    {"01/05/2009", "Dagwood"}
};
So, assuming you wanted to use the functionality in ObservableCollection to observe something
C#
// somewhere in your initialization code
StudentsCollection.CollectionChanged += StudentsCollection_CollectionChanged;  

private void StudentsCollection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
    switch (e.Action)
    {
        case NotifyCollectionChangedAction.Add:
            // new item added
            break;
        case NotifyCollectionChangedAction.Remove:
            // item removed
            break;
        // and so on ...
    }
}

« There is only one difference between a madman and me. The madman thinks he is sane. I know I am mad. » Salvador Dali


modified 27-Oct-14 9:24am.

QuestionExtraction of data from excel to databae Pin
Member 1118244626-Oct-14 21:38
Member 1118244626-Oct-14 21:38 
AnswerRe: Extraction of data from excel to databae Pin
Pete O'Hanlon26-Oct-14 21:41
mvePete O'Hanlon26-Oct-14 21:41 
GeneralRe: Extraction of data from excel to databae Pin
Member 1118244626-Oct-14 21:58
Member 1118244626-Oct-14 21:58 
Questionsimple code for game Pin
cicill26-Oct-14 15:23
cicill26-Oct-14 15:23 
AnswerRe: simple code for game Pin
BillWoodruff26-Oct-14 16:32
professionalBillWoodruff26-Oct-14 16:32 
AnswerRe: simple code for game Pin
Mycroft Holmes26-Oct-14 19:20
professionalMycroft Holmes26-Oct-14 19:20 
AnswerRe: simple code for game Pin
Pete O'Hanlon26-Oct-14 21:38
mvePete O'Hanlon26-Oct-14 21:38 
GeneralRe: simple code for game Pin
harold aptroot27-Oct-14 4:29
harold aptroot27-Oct-14 4:29 
QuestionData binding in wpf Pin
rajeevanagaraj25-Oct-14 2:16
rajeevanagaraj25-Oct-14 2:16 
AnswerRe: Data binding in wpf Pin
Mycroft Holmes25-Oct-14 13:32
professionalMycroft Holmes25-Oct-14 13:32 
QuestionUpload and Save Image Using Webservice Pin
ASPnoob24-Oct-14 23:59
ASPnoob24-Oct-14 23:59 
AnswerRe: Upload and Save Image Using Webservice Pin
CAReed25-Oct-14 4:25
professionalCAReed25-Oct-14 4:25 
GeneralRe: Upload and Save Image Using Webservice Pin
ASPnoob25-Oct-14 7:05
ASPnoob25-Oct-14 7:05 
AnswerRe: Upload and Save Image Using Webservice Pin
Nathan Minier27-Oct-14 1:53
professionalNathan Minier27-Oct-14 1:53 
QuestionApplication could not start error 0xC0000006 starting C# .NET 2.0 program Pin
eljainc24-Oct-14 9:12
eljainc24-Oct-14 9:12 
AnswerRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
Dave Kreskowiak24-Oct-14 10:26
mveDave Kreskowiak24-Oct-14 10:26 
GeneralRe: Application could not start error 0xC0000006 starting C# .NET 2.0 program Pin
eljainc24-Oct-14 10:39
eljainc24-Oct-14 10:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.