Loading collections Questions

kirkkelly

New member
Joined
Oct 24, 2006
Messages
1
Programming Experience
3-5
I need a little help in understanding a what is probably a very basic and easy concept. Everything in .Net is an object, seems like every control from a listbox to a grid, is based on some object be used with .Add() that is assoicated to some collection or another. In all the examples it appears as

1) create an "item" object, set its values, then use the collections .Add() method

and the example is always kind of like below, they name the objects, object1,object2,object3..etc. which is perfect if you know how may objects your going to have.

Example:
VB.NET:
     Dim myResource1 As New DevExpress.XtraScheduler.Resource      
myResource1.Caption = "Room 1"      
Me.SchedulerStorage1.Resources.Add(myResource1)      
Dim myResource2 As New DevExpress.XtraScheduler.Resource      
myResource2.Caption = "Room 2"      
Me.SchedulerStorage1.Resources.Add(myResource2)

In my case, and most others probably, the number is unknown and determined when I get a dataview created. So my question is, how do I load those items into the collection in a generic fashion.

I picture this, but it doesn't seem to work most of the time, leaving only one object created.
Example of what I think should work:

dim oResourceObject as New DevExpress.XtraScheduler.Resource
' Get a dataview with all the records
Dim goResources As DataView = GetDataViewObject.GetDataView(cSQL)
Dim drv2 As DataRowView
For Each drv2 In goMeetProc
oResourceObject.Caption = drv2("ResourceName")
oResourceStartTime = drv2("ResourceStartTime")
Next
Thanks for any pointers
 
Last edited by a moderator:
Around this reorder; for each you create a new object and set properties and add it to collection.
VB.NET:
For Each drv2 As DataRowView In goMeetProc 
 
dim oResourceObject as New DevExpress.XtraScheduler.Resource 
oResourceObject.Caption = drv2("ResourceName") 
Me.SchedulerStorage1.Resources.add(oResourceObject)
 
Next
 
Back
Top