The Collings Zone

The home of Adam & Linda Collings

Welcome to Adam and Linda's place. We are a Christian couple from Tasmania. We have two adorable children. Here you will find some of our writings, and a little other material. Make yourself at home.

Home   |   About Us   |   Adam's Writing   |   Software Projects   |   The Blog

Search the Bible with BibleGateway.com
  
  
  
BibleGateway.com is a service of Gospelcom.net

Wednesday, October 01, 2008

Remove Selection from a ListView Control in eMbedded VB

With The compact .NET framework well established there are probably not many people who are still using eMbedded Visual Basic, but if there are any still working on legacy systems, I have a small tip that helped me today.

I wanted to completely clear the selection on a ListViewCtrl control but there seemed no simple way of doing it. I found that you need to loop through the items and unselect them. Interestingly, it seems that you can't iterate through the ListItems collection using a For Each loop, but a traditional For loop works fine.


Dim lvitem As ListItem
Dim i As Integer

For i = 1 To lstList.ListItems.Count
      Set lvitem = lstList.ListItems(i)
      lvitem.Selected = False
Next i


Theoretically, if you're not using multi-select you should just be able to go

lstList.SelectedItem.Selected = False

but I haven't tested it.

Labels: , ,

0 Comments:

Post a Comment

<< Home