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

Identify item within a combo box on hover

Status
Not open for further replies.

cjac

Programmer
Dec 8, 2003
93
GB
Hi, is there anyway to identify which item you are currently hovering over in a combobox - I want to use this to retrieve relative data - ie. not on the on_click event but just when the user hovers mouse over the item within the drop down combo box?

Or is there any other objects that would be more suited to this?

Cheers
 
To see a very basic example of this, create a new exe and put a combo on form1. Then chuck this code behind the form and run it. It may do what you need it to do. If it does then happy days.

Private Sub Combo1_Change()
Combo1.ToolTipText = Combo1.Text
End Sub

Private Sub Combo1_Click()
Combo1.ToolTipText = Combo1.Text
End Sub

Private Sub Form_Load()
Combo1.AddItem "Some Text Or Other"
End Sub
 
Thanks for the response but this isn't quite what I'm after. The change event is too late - I want to be able to identify which item in the combo box list (not the combo box itself) the mouse hovers over - ie. when the selection is marked by a blue background on the list. I don't think it's possible to be honest. Probably have to come up with some other solution.

Thanks anyway.
 
cjac and JohnCMolyneux,

Actually, it is quite possible (for the majority of practical needs) to do with regular staff. Put timer control and combo box on a form and copy code below into the form.

Option Explicit


Private Sub Combo1_GotFocus()
Timer1.Enabled = True
End Sub

Private Sub Combo1_Validate(Cancel As Boolean)
Timer1.Enabled = False
End Sub

Private Sub Form_Load()
With Combo1
.AddItem "A"
.AddItem "B"
.AddItem "C"
.AddItem "D"
.AddItem "E"
End With

Timer1.Interval = 250
End Sub

Private Sub Timer1_Timer()
Me.Caption = Combo1.List(Combo1.ListIndex)
End Sub

Vladk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top