Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to Unselect item of ListBox?
 

How to Unselect item of ListBox?

Hi,
My Window Form ListBox lbxQuyen with SelectionMode MultiExtended. 
I use the following code to unselect all Item in ListBox, 

for(int k=0;k<lbxQuyen.Items.Count;k++) 

this.lbxQuyen.SetSelected(k,false); 

But this code not run well. 
When I debug this, lbxQuyen.GetSelected(k) is not false. 
Could you tell me why? 
Thanks 
MigrationUser 1  Saturday, April 09, 2005 9:45 PM
That code should work fine...  When are you calling GetSelected()?  So long as your loop has finished, GetSelected() should return false for all indices.

If you just want to clear all selected items, setting the SelectedIndex property to -1 would be more efficient than the loop you're using.
MigrationUser 1  Tuesday, April 12, 2005 12:09 PM
Oh,
Something seem good as you tell if I use a normal form.
But in mdi form, something is not good. 
I do not know why?
Could you help me?
Thanks alot for support. 
MigrationUser 1  Thursday, April 14, 2005 9:39 AM

You can use google to search for other answers

Custom Search

More Threads

• Highlighting a row in a datagridview
• Copying Content to the cell Vertically downwards by dragging
• how to check is specific software is installed or not using java code
• ColumnChanged event not fired when current column value is changed
• Binding a combo box to a data set
• Datasets Disappear in VB.Net MDI App
• Binding Navigator Problem
• Maintaining column width during scrolling
• How can I get the default image of DataGridViewImageCell?
• Update requires a valid UpdateCommand when click Update