|
Hi,
I have a list box where I am reading information from a MS Access Database.
The list box populates when the form is loaded. However, sometimes the information is wider than the list box. I have added scroll bars so user can see the information. However, It would be great if they didn't need to scroll.
I've read that listboxes cannot wrap text so, is there a way to use a double click event on a item to readthat line from the list box and display it in another text field so i can use the mutliline function? Or even better after the item is double clicked a pop up form will appear with the item
Thanks in advance, i hope that made sense
| |
Share:
100+ |
Hi,
I have a list box where I am reading information from a MS Access Database.
The list box populates when the form is loaded. However, sometimes the information is wider than the list box. I have added scroll bars so user can see the information. However, It would be great if they didn't need to scroll.
I've read that listboxes cannot wrap text so, is there a way to use a double click event on a item to readthat line from the list box and display it in another text field so i can use the mutliline function? Or even better after the item is double clicked a pop up form will appear with the item
Thanks in advance, i hope that made sense
hi
this might be a solution -
-
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
-
-
Private Const LB_ITEMFROMPOINT = &H1A9
-
Dim ndx As Long
-
-
Public Function ListBoxHit(ListBox As ListBox, ByVal X As Single, ByVal Y As Single) As Long
-
ndx = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0, (Y \ Screen.TwipsPerPixelY) * 65536 + (X \ Screen.TwipsPerPixelX))
-
If (ndx And &H10000) = &H10000 Then
-
ListBoxHit = -1
-
Else
-
ListBoxHit = ndx
-
End If
-
End Function
-
-
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Label1.Visible = False
-
End Sub
-
-
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
If Button = 2 Then
-
ndx = ListBoxHit(List1, X, Y)
-
If Not ndx = -1 Then List1.Selected(ndx) = True
-
With Label1
-
.Move List1.Left + List1.Width, List1.Top + Y - 60
-
.Caption = " " & List1.List(ndx) & " "
-
.Visible = True
-
End With
-
Else
-
Label1.Visible = False
-
End If
-
End Sub
-
-
-
the listbox = List1
the label=Label1
create:
visible=false
backstyle=opaque
autosize=true
borderstyle=fixed single
backcolor= any color
click with right mouse on a list.item will trigger the label to pop-up
| | |
albertw,
Im still having problems reading the events, the code you provided does implement the click event. However, it will only read the first item int he list box.
for example:
if i have a list with the records 1,2,3,4,5 and i click on 5 it will still display the record for number 1.
hi
this might be a solution -
-
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
-
-
Private Const LB_ITEMFROMPOINT = &H1A9
-
Dim ndx As Long
-
-
Public Function ListBoxHit(ListBox As ListBox, ByVal X As Single, ByVal Y As Single) As Long
-
ndx = SendMessage(List1.hWnd, LB_ITEMFROMPOINT, 0, (Y \ Screen.TwipsPerPixelY) * 65536 + (X \ Screen.TwipsPerPixelX))
-
If (ndx And &H10000) = &H10000 Then
-
ListBoxHit = -1
-
Else
-
ListBoxHit = ndx
-
End If
-
End Function
-
-
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Label1.Visible = False
-
End Sub
-
-
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
If Button = 2 Then
-
ndx = ListBoxHit(List1, X, Y)
-
If Not ndx = -1 Then List1.Selected(ndx) = True
-
With Label1
-
.Move List1.Left + List1.Width, List1.Top + Y - 60
-
.Caption = " " & List1.List(ndx) & " "
-
.Visible = True
-
End With
-
Else
-
Label1.Visible = False
-
End If
-
End Sub
-
-
-
the listbox = List1
the label=Label1
create:
visible=false
backstyle=opaque
autosize=true
borderstyle=fixed single
backcolor= any color
click with right mouse on a list.item will trigger the label to pop-up
| | |
It looks like ndx is not updating with the correct selected record. B/c if you just enter an integer value into the .Caption = " " & List1.List(ndx) & " " it will display the record corresponding to that value. So it seems to be that ndx is constantly remaining the value 0.
albertw,
Im still having problems reading the events, the code you provided does implement the click event. However, it will only read the first item int he list box.
for example:
if i have a list with the records 1,2,3,4,5 and i click on 5 it will still display the record for number 1.
| | Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
8 posts
views
Thread by Bill |
last post: by
|
1 post
views
Thread by Blacky |
last post: by
|
1 post
views
Thread by Edward |
last post: by
|
1 post
views
Thread by Zyrthofar Blackcloak |
last post: by
|
18 posts
views
Thread by Zytan |
last post: by
|
4 posts
views
Thread by Jeff User |
last post: by
|
5 posts
views
Thread by Academia |
last post: by
| |
8 posts
views
Thread by jh |
last post: by
| | | | | | | | | | |