I am using a listbox in my C#2.0 windows forms application. The method to populate the list box is
private void PopulateListBox(ListBox lb, ReportColumnList reportColumnList)
{
lb.DataSource = reportColumnList.ReportColumns;
lb.DisplayMember = "ColumnName";
lb.ValueMember = "ColumnName";
}
However, when it executes the method it also calls the SelectedIndexChanged event handler of the listbox, even though I am not setting the selected index in the method above. How can I prevent the SelectedIndexChanged event handler from being called for the above code?
I want the event to be called only when the user makes the selections in the ListBox. Or is there any other event which is only for user selecting listbox items using mouse click?
On another note, even if the user clicks on an empty area in the list box the SelectedIndexChanged event gets fired. So I am wondering how different is it from the MouseClick event?