Everyone,
Thanks for the responses.
It was exactly what you mentioned. SelectedIndexChanged event to fire twice
and code some code behind effecting it.
Welcome me to the world of Component programming and Event Handlers.
"C Addison Ritchie" <CA*************@discussions.microsoft.com> wrote in
message news:8D**********************************@microsof t.com...
This code works fine for me. One thing to look out for though... setting
the SelectedIndex to any value will cause the SelectedIndexChanged event
to fire. Ensure that you don't have any code in that event that would
cause the issue you are experiencing.
In fact the following code causes the SelectedIndexChanged event to fire
twice.
ArrayList al = new ArrayList(5);
al.Add("Item1");
al.Add("Item2");
al.Add("Item3");
al.Add("Item4");
al.Add("Item5");
comboBox1.DataSource = al;
One other thing I noticed is that after setting the DataSource I didn't
have to even set the SelectedIndex to -1 as the combobox didn't have an
item selected.
--
C Addison Ritchie, MCSD.NET
Ritch Consulting, Inc.
"ScottO" wrote:
I would like the user to have to select something in a
System.Windows.Forms.ComboBox.
private void MyForm_Load(object sender, System.EventArgs e)
{
...
comboBox.DataSource = data;
comboBox.SelectedIndex = -1;
...
}
Above code does work.
Any thoughts?