G
Guest
I'm sure this is something pretty trivial but can't seem to figure out how
to do it.
I'm using Generic Lists in quite a few places in my app and for some of them
want to be able to create a ToString method that would return a formatted
string array.
For example, I might have a simple class as follows:
Class Foo
Public ItemIndex as short
Public Description as string
End Class
There would be a List object containing instances of this class e.g.
Dim MyFoos as List (Of Foo)
now say for populating a drop-down list I want to display items in the
following format:
1 : Item A
2: Item B
3: Item C
etc.
I would like to be able to populate the dropdown list (ddl) using the
AddRange() method, so I'd need something like
ddl.Items.AddRange(MyFoos.ToString).
How would I implement this method? I've tried creating my own NumberedList
class which inherits from Generic.List but couldn't see how I could access
the list itself.
Thanks in advance
to do it.
I'm using Generic Lists in quite a few places in my app and for some of them
want to be able to create a ToString method that would return a formatted
string array.
For example, I might have a simple class as follows:
Class Foo
Public ItemIndex as short
Public Description as string
End Class
There would be a List object containing instances of this class e.g.
Dim MyFoos as List (Of Foo)
now say for populating a drop-down list I want to display items in the
following format:
1 : Item A
2: Item B
3: Item C
etc.
I would like to be able to populate the dropdown list (ddl) using the
AddRange() method, so I'd need something like
ddl.Items.AddRange(MyFoos.ToString).
How would I implement this method? I've tried creating my own NumberedList
class which inherits from Generic.List but couldn't see how I could access
the list itself.
Thanks in advance