Hi All.
First of all I have a datasource in my winforms project where I needed to bind the text in a checkedlistbox to a nested property in this case the "Name"
object[0] --> type of ILink --> Name = "adobe"
object[1 ]--> type of ILink --> Name = "flash"
To accomplish this I found a smarter guy here who led me to a structure like with the relevant code in the GetView() method.
The problem is that this doesn't work for a webcontrol , GetView() doesnt get called. So I'd love to know what modifications I would need to support a webcontrol using this method.
public class ILinkCollection : List<ILink>, ITypedList
{
}
public class ILinkProgramView : IILinkViewBuilder
{
public PropertyDescriptorCollection GetView()
{
List<PropertyDescriptor> props = new List<PropertyDescriptor>();
IProgramDelegate del = delegate(ILink d)
{
return d.Program.Name;
};
props.Add(new ILinkProgramDescriptor("FullName", del, typeof(string)));
del = delegate(ILink dl) { return dl.IsActive; };
props.Add(new ILinkProgramDescriptor("IsActive", del, typeof(string)));
PropertyDescriptor[] propArray = new PropertyDescriptor[props.Count];
props.CopyTo(propArray);
return new PropertyDescriptorCollection(propArray);
}
}
public class ILinkProgramDescriptor : PropertyDescriptor
{
}
I then set the datasource like so
ILinkCollection iLinkPrograms = new ILinkCollection(new ILinkProgramView());
clbProgs.DataSource = iLinkPrograms;
clbProgs.DisplayMember = "FullName";
clbProgs.ValueMember = "IsActive";