D
David J Rose
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;
}
set
{
base.List = value;
}
}
}
Thanks
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;
}
set
{
base.List = value;
}
}
}
Thanks