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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listview deselect problem

Status
Not open for further replies.

NSNewey

Programmer
Jun 29, 2005
125
GB
Hi,

I have a listview control in an Access 2003 form.

When the list is populated from code, the SelectedItem is always the first item in the list.

How can I deselect the listview so no items are selected.

I have tried lstView.SelectedItems.Clear which is the .net way but in access an error reports that this method is not supported.

Any ideas please???
 
You said listView not listBox, but I assume you mean ListBox. Am I right?

To clear the selected items from a ListBox, try:
[tt]
MyListbox = 0
[/tt]
 
No, I meant a ListView Control.
It's an active X control that is more functional than the plain old listbox.

Any ideas anyone?
 
Problem solved, found the answer.

Posted it in case anyone else finds it useful...

Code:
[COLOR=green]'to completely deselect a listView[/color]
If Not ListView1.SelectedItem Is Nothing Then
   ListView1.SelectedItem.Selected = False
   Set ListView1.SelectedItem = Nothing
End If

Now when you want to test for a selection...
Code:
If Not ListView1.SelectedItem Is Nothing Then
   lValue  = ListView1.SelectedItem
Else
   msgBox ("No Selection")
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top