|
-
Apr 16th, 2006, 02:20 AM
#1
Thread Starter
Hyperactive Member
C# code help...
Hello Good Morning!!!
I have been spending lot of hours these days trying to learn c#.
I am doing a practice excercise (windows forms application) and I have come across an issue and I tried quiet a bit but no success yet. I was wondering if any one of C-sharpers in this forum and guide me thru this problem.
I have created a product class (base class) and two sub classes (derived classes) called Books and DVD's (that inherit, from Product base class).
I was able to load both books and dvd objects into an array list and I loaded the contents of the array list into a list box in the Load event of the form.
BTW, the question is about scope the array list that I am using here.
So far so good. I have provided to radio buttons (Books only, DVD's Only) on the same form. If the user chooses "Books only" radio button, then only the books objects should be populated in the list box.
So I was planning to use GetType method of system.object class to determine what kind of objects in the arraylist (that I have loaded in form_load event) . But by the time, the user clicks on the radio button, the array list is not in scope and there are no more objects (book objects and DVD objects) in the array list.
Where should I declare the Arraylist (I named it as "allProducts") so that the contents of the arrayList are not lost and the content would exist throught out the form. I want to load the arrayList with all objects (both books and DVD's) only once in the Load event. ? currently I declared the allProducts arraylist in Load event of the form.
Or is there any other alternate way that I should do the population of all objects into the arrayList so that I won't loose the contents of the arraylist in the entire form class?
thanks
nath
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|