P
Paul Wheeler
Question:
Is it possible to dynamicly bind a ComboBox to the list of tables in a
dataset?
Details:
I'm working on binding a Windows Forms ComboBox's collection to the list of
tables in a data set.
I need the binding to be dynamic so that when I add tables to my dataset, my
combobox gets updated too. While I could add a handler to the
DataTableCollection's CollectionChanged event that would update my
combobox's list, I would prefer to avoid this.
The problem is that the DataTableCollection implements ICollection, but not
IList (which doesn't make sense to me), so I cannot set the ComboBox's
DataSource property directly to the DataTableCollection. And while
DataTableCollection does contain a protected field List which is an IList
representation of the DataTableCollection, the DataTableCollection class
cannot be inherited because it contains a private constructor, so the field
is inaccessible. (If anybody can explain the reason for this design I would
be interested to know)
My current alternative is to create an ArrayList from the
DataTableCollection using the ArrayList(ICollection) constructor, but this
makes a copy of the data, and is therefore not dynamic, thus defeating the
entire purpose.
Thanks Much,
-Paul Wheeler
P.S. This is my first time posting here, so I apologize if I have violated
any rules a etiquette
Is it possible to dynamicly bind a ComboBox to the list of tables in a
dataset?
Details:
I'm working on binding a Windows Forms ComboBox's collection to the list of
tables in a data set.
I need the binding to be dynamic so that when I add tables to my dataset, my
combobox gets updated too. While I could add a handler to the
DataTableCollection's CollectionChanged event that would update my
combobox's list, I would prefer to avoid this.
The problem is that the DataTableCollection implements ICollection, but not
IList (which doesn't make sense to me), so I cannot set the ComboBox's
DataSource property directly to the DataTableCollection. And while
DataTableCollection does contain a protected field List which is an IList
representation of the DataTableCollection, the DataTableCollection class
cannot be inherited because it contains a private constructor, so the field
is inaccessible. (If anybody can explain the reason for this design I would
be interested to know)
My current alternative is to create an ArrayList from the
DataTableCollection using the ArrayList(ICollection) constructor, but this
makes a copy of the data, and is therefore not dynamic, thus defeating the
entire purpose.
Thanks Much,
-Paul Wheeler
P.S. This is my first time posting here, so I apologize if I have violated
any rules a etiquette