|
-
Jun 2nd, 2000, 06:57 AM
#1
Thread Starter
Hyperactive Member
Before I tear out the rest of my hair - can someone tell me how to make a listbox show multiple lines or a combo box wrap the text when the entry is larger than the box itself? I need this so that when the related field has an entry that is long, the user can read the entire entry rather than just part of it. Is this possible with the list or combo box or any of the other data bound list controls?
Thanks
Andrew
-
Jun 2nd, 2000, 08:50 AM
#2
There are a few solutions you could use;
1. You could use the ListView control, (Part of the Microsoft Common Controls collection), setting the View property to 0 - lvwIcon it will wrap the Item description, setting it to 1 - lvwSmallIcon will provide a Horizontal Scrollbar to allow the user to view the rest of the Item text.
2. You could use the SendMessage() API with the LB_SETHORIZONTALEXTENT constant to add a Horizontal scrollbar to your Listbox allowing the user to scroll and see the whole item, i.e.
Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const LB_SETHORIZONTALEXTENT = &H194
Private Sub Form_Load()
SendMessage List1.hwnd, LB_SETHORIZONTALEXTENT, 300, ByVal 0&
List1.AddItem "Really, Really, Really, Really, Really, Really Long List Item"
End Sub
3. You could use the ToolTipText property of the Listbox to show the user the whole ListItem text, i.e.
Code:
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Private Const LB_ITEMFROMPOINT = &H1A9
Private Sub Form_Load()
Dim iIndex As Integer
'Fill the List with Dummy Values
For iIndex = 1 To 100
List1.AddItem "Really, Really, Really, Really, Really Long List Item " & iIndex
Next
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim tPOINT As POINTAPI
Dim iIndex As Long
'Get the Mouse Cursor Position
Call GetCursorPos(tPOINT)
'Convert the Coords to be Relative to the Listbox
Call ScreenToClient(List1.hWnd, tPOINT)
'Find which Item the Mouse is Over
iIndex = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0&, ByVal ((tPOINT.X And &HFF) Or (&H10000 * (tPOINT.Y And &HFF))))
If iIndex >= 0 Then
'Extract the List Index
iIndex = iIndex And &HFF
'Set the Lists ToolTipText
List1.ToolTipText = List1.List(iIndex)
End If
End Sub
Hope one of them is useful to you,
- Aaron.
-
Jun 2nd, 2000, 09:24 AM
#3
_______
databound textbox can be multiline
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 2nd, 2000, 09:53 AM
#4
I have created a multi lined listbox (ActiveX control) a while ago that has the same properties as listbox, but allows you to have MultiLined text in list item.
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
|