using collectionbase derivative as datasource

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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


.



Relevant Pages

  • Re: using collectionbase derivative as datasource
    ... 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 ... private int index; ... public Test(int index, string value) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: using collectionbase derivative as datasource
    ... objects "TestCollection", what do I need to add to the class to let me set ... private int index; ... public Test(int index, string value) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: finding an index in an STL vector<>
    ... "Joe" wrote in message ... > I want to find the index of the element containing a certain string. ... David Hilsee ...
    (comp.lang.cpp)
  • Re: conversion to c# from excel function help
    ... public static string CellIndexToName (int index) ... I found it when I was looking for a>function to convert numbers to excel like headers. ... >>> Function Num2LetAs String ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How to build a Design Time PropertyGrid
    ... public class MyOBject ... public string Name ... public class MyObjectCollection:CollectionBase ... public void Insert(int index, MyOBject value) ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)