Gladimir Posted May 20, 2003 Posted May 20, 2003 (edited) I think I am doing something wrong with my listbox control. The Selection Mode is multi-extended and the DataSource is bound to a dataset table resulting from a query. Everything works wonderfully, until I deselect the last selected item in the Listbox. When I deselect the last selected item in the Listbox, by holding the Control key and clicking the last selected item, the first item in the list becomes selected. I have code in only one event for this listbox and that is the SelectedIndexChanged event and here is the code: private void listMatches_SelectedIndexChanged (object sender, System.EventArgs e) { buttonExclude.Enabled = false; buttonCommit.Enabled = false; // update exclude/commit buttons if (listMatches.SelectedItems.Count > 0) { buttonExclude.Enabled = true; buttonCommit.Enabled = true; } labelSelected.Text = listMatches.SelectedItems.Count.ToString(); } Edited May 21, 2003 by Gladimir Quote Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte
Moderators Robby Posted May 21, 2003 Moderators Posted May 21, 2003 Have you tried the same actions while commenting the above code? Quote Visit...Bassic Software
wyrd Posted May 21, 2003 Posted May 21, 2003 Yeah I'm with Robby here, the above code doesn't seem to do anything that would suggest selecting another item in the list. Perhaps you should run it in debug mode and step through each line of code to find out what exact line is causing the strange selection to occur. Quote Gamer extraordinaire. Programmer wannabe.
Gladimir Posted May 21, 2003 Author Posted May 21, 2003 Might be a bug... Well, I've done some experimentation and think this could be a bug in the ListBox control. I started a new project, threw a listBox on the form, set the SelectMode to MultiExtended, and populated it use the Add method. The multi-select and deselect worked as expected. However, when I populate the same ListBox by assigning a DataSet table to the DataSource property, I get the disfunctional multi-select and deselect behavior. Any ideas? Quote Never ascribe to malice that which is adequately explained by incompetence. - Napoleon Bonaparte
wyrd Posted May 21, 2003 Posted May 21, 2003 Try binding the Table's Default View and see if that solves the problem. It may very well be an odd bug with the ListBox. Quote Gamer extraordinaire. Programmer wannabe.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.