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!

Responding to mouse move over items in combo box

Status
Not open for further replies.

TimSzrejter

Programmer
Feb 13, 2001
18
0
0
US
I have a combo box on a form. The combo box has 3 items to select from. I want a label next to the combo box to populate with a description for each choice as the user moves the mouse over the items of the combo box. Is there a way in the mouse move event of the combo box to see which item is currently highlighted in the combo box so I can change the description in the label accordingly?

Thanks,
Timothy Szrejter
 
You might be able to, but it won't be easy. You will have to figure out the possible X and Y coordinates for each entry and if your entries are dynamic, that could be a headache.

This code will give you the X and Y coordinates of the mouse if you hold the mouse over the combo box. My combobox was named Country, so you will have you change this to suit your needs.

Private Sub country_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

Me!country.ControlTipText = "X is " & X & ". Y is " & Y

End Sub


Hope this helps Kathryn


 
You may want to use the Select Case statement. It would go in the Mouse Move event and look sort of like this:

Select Case YourComboBox
Case Is = "Value1"
Lable.Caption = "Description One"
Case Is = "Value2"
Lable.Caption = "Description Two"
Case Is = "Value2"
Lable.Caption = "Description Three"
End Select

You would replace YourComboBox with the name of your box. Value1, 2 and 3 are the the three items in your combo box. Of course you will replace Lable.Caption with your lable's name.Caption.

Good luck. ljprodev@yahoo.com
Professional Development
MS Access Applications
 
Lonnie,

Would that work without actually clicking on the combo box? If I read the original post correctly, Timothy wants the text to appear as he moves the mouse.

Timothy,

Could you clarify?

Kathryn


 
Yes, I want it to appear as the pointer moves over the options and before you actually select an option. I thought the combo box would be like a list box and have a "SelectedItem" property but it doesn't.
 
Yes. I tested this routine by putting the values of "Hello" and "Goodbye" in the list. I set my select case to render a message box that said hello and goodbye respectively depending upon which was selected. When I passed the mouse over the box (also works for listboxes) I got the appropriate message box. ljprodev@yahoo.com
Professional Development
MS Access Applications
 
I want to be able to pass my mouse over the drop down portion of the combo box. Does your Select statement work in the drop down portion of the combo box Lonnie?
 
Timothy,

There is a Text property, that gives you the selected text value. Would that help you? Kathryn


 
No this does not work for the combo box's dropdown portion. You may want to go with Kathryn's text property or create a second column to your droplist that would have the descriptions for each line. ljprodev@yahoo.com
Professional Development
MS Access Applications
 
Ok. I got it to work this way. As I move my mouse over the possible options which are High, Medium, and Low I get the output to my label.

Select Case Y
Case 240 To 479
lblPriorityDescription.Caption = "High desc."
Case 480 To 719
lblPriorityDescription.Caption = "Medium desc."
Case 720 To 960
lblPriorityDescription.Caption = "Low desc."
Case Else
lblPriorityDescription.Caption = ""
End Select

Thanks for everyones help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top