|
-
Oct 18th, 2001, 07:32 PM
#1
Thread Starter
Lively Member
Combo Box and Tooltips
Hi All,
I have created a combo box and added a list of sotfware titles.
When I click on the drop down button the titles are populated in the combo boxes list view. Some of these titles are longer then the combo box.
What I was wondering is if there is a way to check the titles in the drop down list of the combo box (as the mouse moves over). and if the text is too long (in the drop down portion of the combo box) have it displayed in the tooltip?
Thanks.
-
Oct 18th, 2001, 08:42 PM
#2
ToolTipText is only when the object is in "wait mode" I do not think you can see the the ToolTipText can be seen when the combo box are open. If the combo is close you can use
Combo1.ToolTipText = Combo1.Text
-
Oct 18th, 2001, 08:45 PM
#3
Here si an exemple :
VB Code:
Private Sub Combo1_Click()
Combo1.ToolTipText = Combo1.Text
End Sub
Private Sub Form_Load()
Combo1.Clear
Combo1.Width = 1000
Combo1.AddItem "LongStringWhoILikeALot"
Combo1.AddItem "LittleString"
End Sub
Here is the picture :
-
Oct 18th, 2001, 09:27 PM
#4
Here's an alternative to using tooltips. Instead, you modify the width of only the dropdown portion of the combo...
VB Code:
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const CB_SETDROPPEDWIDTH = &H160
Public Const CB_ERR = (-1)
Public Sub SetDropDownWidth(mCombo as ComboBox)
Dim RetVal As Long
Dim PixelWidth As Long
Dim MaxWidth As Long
Dim LoopCounter As Long
Dim lWidth As Long
For LoopCounter = 0 To mCombo.ListCount - 1
lWidth = mCombo.Parent.TextWidth(mCombo.list(LoopCounter))
If lWidth > MaxWidth Then
MaxWidth = lWidth
End If
Next LoopCounter
MaxWidth = MaxWidth + (23 * Screen.TwipsPerPixelX)
If MaxWidth > (mCombo.Width * 2) Then
MaxWidth = (mCombo.Width * 2)
Elseif MaxWidth < mCombo.Width Then
MaxWidth = mCombo.Width
End If
PixelWidth = (MaxWidth \ Screen.TwipsPerPixelX)
RetVal = SendMessage(mCombo.hwnd, CB_SETDROPPEDWIDTH, PixelWidth, 0)
End Sub
- gaffa
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|