Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem clearing selections in listbox

Status
Not open for further replies.

enak

Programmer
Jul 2, 2002
412
US
I have a listbox in a winform. It is set for multiple selections. However, I need to be able to un-select all of the items in the list. Here is what I am doing:

For j = 0 To UBound(arClass)
For i = 0 To Me.lstMgrClassifications.Items.Count - 1
If arClass(j) = (CType(CType(CType(Me.lstMgrClassifications.Items(i), Object), System.Data.DataRowView).Row, System.Data.DataRow).ItemArray(0)) Then
Me.lstMgrClassifications.SetSelected(i, True)
Exit For
Else
Me.lstMgrClassifications.SetSelected(i, False)
End If
Next
Next

This works well except for the very first item in the list. It is always selected.

How can I un-select it?

Thanks,
enak
 
If you are trying to de-select all the items in a listbox. Add a button to the form and insert this code:

ListBox1.ClearSelected()


-mike
 
That was it, thanks. I just didn't see it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top