Click here to Skip to main content
16,006,378 members
Home / Discussions / C#
   

C#

 
GeneralRe: Installer won't overwrite previous version? Pin
Iftekhar Naim23-Jun-07 20:40
Iftekhar Naim23-Jun-07 20:40 
GeneralRe: Installer won't overwrite previous version? Pin
Jasmine250123-Jun-07 23:02
Jasmine250123-Jun-07 23:02 
GeneralRe: Installer won't overwrite previous version? Pin
Iftekhar Naim24-Jun-07 21:23
Iftekhar Naim24-Jun-07 21:23 
GeneralRe: Installer won't overwrite previous version? Pin
Jasmine250125-Jun-07 10:41
Jasmine250125-Jun-07 10:41 
QuestionUninstallation problem Pin
Iftekhar Naim23-Jun-07 16:08
Iftekhar Naim23-Jun-07 16:08 
AnswerRe: Uninstallation problem Pin
Jasmine250123-Jun-07 17:59
Jasmine250123-Jun-07 17:59 
GeneralRe: Uninstallation problem Pin
Iftekhar Naim23-Jun-07 19:33
Iftekhar Naim23-Jun-07 19:33 
QuestionNeed help with Collection vs. List in "Storage" Class [modified] Pin
CSharpByDesign23-Jun-07 16:02
CSharpByDesign23-Jun-07 16:02 
Hi everyone, this was an email to a friend that doesn't seem to be around.. perhaps you guys can help me out here ? I hope the examples I provided are clear enough. I'm having a bit of a problem grapsing the exact concept of what I need to do. An example or point to a good resource would be fantastic!! Thank you all in advance:

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

public class tbl_someTable {
private string field1;
private string field2;

public string Field1 {
get { return field1; }
set { _field1 = value; }
}

public string Field2 {
get { return field2; }
set { field2 = value; }
}
}

So above is a class, representing a table in my database. Now, think ‘big’ and there are several of these, covering all sorts of tables. Now, I want a ‘storage’ class, which stores information about something that’s currently going on. I create that object, and have it wired with change events..

public partial class StateObject {
[event declarations for an “onStateObjectChanged” event]

private tbl_someTable _someTable;
public tbl_someTable someTable {
get { return _someTable; }
set {
_someTable = value;

onStateObjectChanged(this,new StateObjectEventArgs(“someTable”));
}
}
}

Now, the above works GREAT !!! In usage :


StateObject stateObject = new StateObject();
stateObject.StateObjectChanged += delegate ( object S, StateObjectEventArgs E) {
MessageBox.Show(“Called. – “ + E.TableThatCalledMe);
};

stateObject.someTable = new tbl_someTable();
stateObject.someTable.Field1 = “Hello”;
stateObject.someTable.Field2 = “World”;



The above, would generate two events! That’s ok, still not optimal.. but whatever. At least I know something changed! I might not want to know that those two fields changed, but what can I do ?

-- NOW – The problem.

public partial class StateObject {
private List<tbl_someothertable> _someOtherTable = new List<tbl_someothertable>();
public List<tbl_someothertable> someOtherTable {
// Get / Set accessors
// No way to fire them!!!
}
}


tbl_someOtherTable x = new tbl_someOtherTable();
x.name = "Test 1";
stateObject.someOtherTable.Add(x); // as an example
x = new tbl_someOtherTable();
x.name = "Tets 2";
stateObject.someOtherTable.Add(x);

I would get no notifications!

I understand that perhaps I should be using the Collection<t> class instead, because I can override the add/remove/etc. events ? – well, I don’t know how to do that, or implement it in StateObject properly ?

I realize, I’ll probably have to create another class, that inherits from tbl_someOtherTable and implements ICollection<t> ? Then I can get notifications and such, but I’m not sure how to wire them into the original class ? – or just subscribe to them in a constructor or something, and make it fire the main [StateObject] event that notifies other things ? What I really need is an example that doesn’t confuse me! I think I have a pretty good grasp on this… but I’m just not quite there. I need to store a list of objects [think, items in a cart!] and be able to access them easily!

Thank you !


-- modified at 22:16 Saturday 23rd June, 2007


- Matthew

Questionproblem with client server socket application Pin
Iftekhar Naim23-Jun-07 15:50
Iftekhar Naim23-Jun-07 15:50 
QuestionLibrary Problem Pin
max2929723-Jun-07 12:21
max2929723-Jun-07 12:21 
AnswerRe: Library Problem Pin
Ed.Poore23-Jun-07 12:44
Ed.Poore23-Jun-07 12:44 
AnswerRe: Library Problem Pin
Christian Graus23-Jun-07 13:16
protectorChristian Graus23-Jun-07 13:16 
QuestionTyped Dataset Pin
TheEagle23-Jun-07 9:20
TheEagle23-Jun-07 9:20 
AnswerRe: Typed Dataset Pin
WillemM23-Jun-07 10:20
WillemM23-Jun-07 10:20 
GeneralRe: Typed Dataset Pin
TheEagle27-Jun-07 7:11
TheEagle27-Jun-07 7:11 
QuestionAdding new User to Windows XP ??? Pin
zinc_z23-Jun-07 8:18
zinc_z23-Jun-07 8:18 
AnswerRe: Adding new User to Windows XP ??? Pin
Giorgi Dalakishvili23-Jun-07 8:32
mentorGiorgi Dalakishvili23-Jun-07 8:32 
GeneralRe: Adding new User to Windows XP ??? [modified] Pin
zinc_z23-Jun-07 9:13
zinc_z23-Jun-07 9:13 
QuestionBeginning Databases Pin
alostdruid23-Jun-07 8:12
alostdruid23-Jun-07 8:12 
AnswerRe: Beginning Databases Pin
WillemM23-Jun-07 10:14
WillemM23-Jun-07 10:14 
QuestionXamlParseException whenever assigning values to C# class member Pin
Kris10023-Jun-07 7:23
Kris10023-Jun-07 7:23 
AnswerRe: XamlParseException whenever assigning values to C# class member Pin
Ed.Poore23-Jun-07 9:52
Ed.Poore23-Jun-07 9:52 
AnswerRe: XamlParseException whenever assigning values to C# class member Pin
WillemM23-Jun-07 10:16
WillemM23-Jun-07 10:16 
QuestionAbstract and inheriting Pin
Brendan Vogt23-Jun-07 7:04
Brendan Vogt23-Jun-07 7:04 
AnswerRe: Abstract and inheriting Pin
DavidNohejl23-Jun-07 7:16
DavidNohejl23-Jun-07 7:16 

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.