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!

How do I turn off the listbox highlight bar

Status
Not open for further replies.

rustychef

Technical User
Sep 2, 2004
63
US
Is it even possible to turn off the highlight bar in a listbox? I have a frmMain that has three listboxes available for the user to select from. I would like to be able to turn off the highlight bar from the two inactive listboxes so its not a confusing to users when all three have a "highlighted" selection. Thanks for any help.
 
I believe what you want to do is this:

[tt]ListBox2.Value = ""
ListBox3.Value = ""
[/tt]
Or, have I misinterpreted your question?

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
If I understand your answer correctly,

ListBox2.Value = ""
ListBox3.Value = ""

would set the current values to nothing.
What I want to do is to "turn off" the highlighting (that may be an incorrect term to use). When you select an item in a listbox, the "active" selection becomes an inverse highlighting, showing the item that you clicked on. I use thre listboxes for employee information(one for onshift, one for out of office, and one for employees temporarily "farmed out").

When I initially click on "GEORGE", an "onshift" employee, the active selection (GEORGE) becomes highlighted.

Then when I click on "TOM", an "out of office" employee, that active selection (TOM) is highlighted IN ADDITION, "GEORGE" from "onshift" listbox is still highlighted.

What I want to do, Is when I make the second selection (clicking on "TOM"), I want "GEORGE"s highlighting to turn off.
 
You have the multiple select option turned on. Turning it off will only allow one item to be selected at a time.

lstbox.MultiSelect = False
 
Rustychef:

In an appropriate event try this:

Dim intLoop as Integer

For intLoop = 0 To lstName.ListCount - 1
lstName.Selected(intLoop) = False
Next intLoop
lstName.Enabled = False

This will reset all selected values to False and disable the list box.

In the appropriate event, re-enable as necessary.

Larry De Laruelle

 
Larry De Laruelle, Thanks I believe that was what I was looking for. Now I have a few other problems to figure out (Im re-coding someone elses half finished database)
 
Hi RustyChef,
I gave ClFlVa's suggestion a try, it seemed to work fine.
Not to mention, of course, Larry De Laruelle's will work equally well.

For ease & speed, ClFlVa's seems sufficient, possibly as such...

Private Sub ListBox1_Click()
ListBox2.Value = "": ListBox3.Value = ""
End Sub

Private ListBox2_Click()
ListBox1.Value = "": ListBox3.Value = ""
End Sub

Private ListBox3_Click()
ListBox1.Value = "": ListBox2.Value = ""
End Sub

I like the idea of disabling, but wasn't sure, with the process I used, how to re-enable?

Thx to both cLFlaVa & Larry!
Hope this helps!
 
You can also use the ListIndex property to set which row is selected. Setting this property to -1 means that no row is selected. The listbox has to have the focus first though:
Code:
lstMyList.SetFocus
lstMyList.ListIndex = -1
Screen.PreviousControl.SetFocus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top