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

Visual Basic 6: List box w/ Checkmarks 1

Status
Not open for further replies.

lennyh

Programmer
Sep 22, 2001
33
0
0
US
When looping through a list box w/ checkmarks as follows:

for i=0 to list1.listcount-1
list1.selected(i)=True
next

the checkmarks are clicked on correctly, but depending upon the previous state of the list items, some of the list items themselves are highlighted. The list items that are highlighted appear to be random (at least I don't see the pattern). This also occurs when deselecting the list items (list1.selected(i)=false).

I'd like to be able to set the checkmarks on/off w/o causing the list items themselves to be highlighted.

Can someone tell me how to do this?

Thank you

Lenny Harris

 

Not quite sure of this because normally if the List Style is set to control check box, you cannot have multiple items selected.
After your loop, add this and see if it helps:
List1.ListIndex = -1
 


>you cannot have multiple items selected

What I meant by this is the Property "MultiSelect" cannot be set to True, meaning that multiple rows are not highlighted - just possibly checked - and only the current row is highlighted.
 
LostInCode, thank you for your speedy response. Your suggestion re ListIndex did the trick. It provided exactly the behavior I was seeking.

Thanks again for your help.

Lenny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top