Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
List1.ToolTipText = List1.Text
End If
End Sub
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
i'm modified andreRet code a bit ;)
Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Or KeyCode = vbKeyUp Then
List1.ToolTipText = List1.List(List1.ListIndex + 1)
End If
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
hmm..i got wrong here..
Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyDown Then
List1.ToolTipText = List1.List(List1.ListIndex + 1)
ElseIf KeyCode = vbKeyUp Then
List1.ToolTipText = List1.List(List1.ListIndex - 1)
End If
End Sub
Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
ToolTipText is display at the cursor.
a better work around is to
1. use a label
2. change the caption
3. move it around as desired with controlled visibility.
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
Tooltiptext will only work when the mouse is over the control. That is what you have asked for, is it not?
To show the result, use a label that will "popup" where the mouse is as per Debasisdas's post, or use a messagebox.
Thanks JX for the correction (-1 or +1).:)
If KeyCode = vbKeyDown Then
Msgbox List1.List(List1.ListIndex + 1)
ElseIf KeyCode = vbKeyUp Then
Msgbox List1.List(List1.ListIndex - 1)
End If
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Ah, a picture CAN speak a thousand words.;)
The "tooltip" there is actually a pop up menu, easy to get if you know how.
In your app, create a menu, then call the popup from there.
Do you know how to achieve this.
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Yes you can. I use it a lot, especially in datagrids.
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
A small tutorial -
Click on "Menu Editor" in your toolbar.
Leave "Caption" empty.
Enter "mnuPopUp" in the "Name" box
De-select "Visible". You do not want the menu to be visible until you call it.
Click on "Next" to insert another menu line.
Click on the "-->" arrow button to create the sub menu
In "Caption", add "List Name: "
Enter "lstName" in "Name" box
Click on "OK". The menu is now created.
To show the pop up where the mouse is, use the following -
Private Sub Command1_Click()
mnuList.Caption = List1.Text
PopupMenu mnuPopUp
End Sub
You can also show the popup over the listbox by adding -
Private Sub Command1_Click()
mnuList.Caption = List1.Text
PopupMenu mnuPopUp, , List1.Left, List1.Top + 150
End Sub
This is a rough sample, you need to tweak it to work for you. If you have any other questions about the popup menu, please open a new thread, I think the original question has been answered here.
Also mark this as solved, found at the bottom of this page, thanks.:)
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
When this thread was started you were asking about ToolTipText but now you have ended up creating a Context Menu. They are not one and same. While ToolTipText is just informational in nature, PopupMenu serves totally different purpose.
debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
why don't you try this...
1. put a label control and keep incrementing its top position from the list top position and keep displaying ur list items.
2. put a timer pause for 5-10 sec...if no key is pressed blank the label caption.
dspnhn
Junior Poster in Training
90 posts since May 2008
Reputation Points: 20
Solved Threads: 13
You can use -
PopupMenu MnuPopup.Visible = False
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
As per my previous post (5 back), we have given you the solution to this question. You wanted to know about tooltiptext using down or up arrows. The popup menu sample is a new solution to what you need because tooltiptext will not work. That is why I have asked you to please CLOSE this thread and open a new one with your questions about popupmenus. I will not answer any more questions here, only on the new thread, and if this is marked as solved.:)
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350