I am using GetEnumerator for determining how many ListBox controls exist
on a form and then binding each of them to a datasource.
This is required as I need to add more Listbox controls to the form as
required.
All my controls are setup similar to the following:
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.TabControl tabControl1;
and they are global to a class called "MainForm".
As a part of this class, there is a method:
private void BindListBoxes()
I call this method from the "Mainform" constructor.
Within BindListBoxes(), is the following code:
private void BindListBoxes()
{
string controlType;
IEnumerator posControls = Controls.GetEnumerator();
while (posControls.MoveNext())
{
Control posControl = (Control) posControls.Current;
controlType = posControl.Name;
MessageBox.Show(controlType);
}
}
This results in only one of the controls being displayed in the
MessageBox: The "tabControl1" control. I am having trouble determing how
to write the code necessary to see all of the other controls on the
form.
Incidentally, the code above is just an initial phase of developing what
is required to bind a datasource to each ListBox.
Any ideas?
*** Sent via Developersdex http://www.developersdex.com ***