using collectionbase derivative as datasource
- From: "David J Rose" <david.rose@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 29 Apr 2005 12:21:25 -0400
If I define my own classes for an object "Test" and a collection of those
objects "TestCollection", what do I need to add to the class to let me set
the collection as a datasource for a listbox and have it automatically
update whenever an item is added/edited or removed from the collection?
Here are the classes:
public class Test
{
private int index;
private string value;
public Test(int index, string value)
{
this.index = index;
this.value = value;
}
public int Index
{
get
{
return index;
}
}
public string Value
{
get
{
return value;
}
}
public override string ToString()
{
return value;
}
}
public class TestCollection : CollectionBase
{
public int Add(Test test)
{
return base.List.Add(test);
}
public Test this[int i]
{
get
{
return (Test)base.List[i];
}
set
{
base.List[i] = value;
}
}
}
Thanks
.
- Follow-Ups:
- Re: using collectionbase derivative as datasource
- From: Jianwei Sun
- Re: using collectionbase derivative as datasource
- From: Jianwei Sun
- Re: using collectionbase derivative as datasource
- Prev by Date: Re: Linking options
- Next by Date: Re: why use the static function ?
- Previous by thread: Terminating application during class initialization
- Next by thread: Re: using collectionbase derivative as datasource
- Index(es):
Relevant Pages
|