Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default select row in userform listbox with right-click?

Is it possible to select a row in a listbox in a userform with a right-click
and still have the right-click event?
I have seen solutions for this in VB using the Windows API, but it doesn't
seem possible with VBA.
Thanks for any advice.

RBS
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default select row in userform listbox with right-click?

Hi RB

You'll probably need to fine tune it for your design. But this works here
with Tahoma og various sizes.:

Private Sub ListBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim L As Long
If Button = 2 Then
L = ListBox1.TopIndex + Int(Y / (ListBox1.Font.Size * 1.2))
ListBox1.ListIndex = L
End If
End Sub

HTH. Best wishes Harald

"RB Smissaert" skrev i melding
...
Is it possible to select a row in a listbox in a userform with a

right-click
and still have the right-click event?
I have seen solutions for this in VB using the Windows API, but it doesn't
seem possible with VBA.
Thanks for any advice.

RBS



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default select row in userform listbox with right-click?

Harald,

Thanks for that!
Beautifully simple and it works perfect.
Don't know why I hadn't come up with this myself.

RBS


"Harald Staff" wrote in message
...
Hi RB

You'll probably need to fine tune it for your design. But this works here
with Tahoma og various sizes.:

Private Sub ListBox1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Dim L As Long
If Button = 2 Then
L = ListBox1.TopIndex + Int(Y / (ListBox1.Font.Size * 1.2))
ListBox1.ListIndex = L
End If
End Sub

HTH. Best wishes Harald

"RB Smissaert" skrev i melding
...
Is it possible to select a row in a listbox in a userform with a

right-click
and still have the right-click event?
I have seen solutions for this in VB using the Windows API, but it

doesn't
seem possible with VBA.
Thanks for any advice.

RBS




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default select row in userform listbox with right-click?

Glad to hear that. Thanks for the feedback.

Best wishes Harald

"RB Smissaert" skrev i melding
...
Harald,

Thanks for that!
Beautifully simple and it works perfect.
Don't know why I hadn't come up with this myself.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox in UserForm Dale Fye Excel Discussion (Misc queries) 0 October 11th 07 09:40 PM
UserForm Listbox in VBC Marcia3641 Excel Discussion (Misc queries) 7 July 22nd 05 10:20 AM
UserForm ListBox Otto Moehrbach[_6_] Excel Programming 3 December 30th 03 06:22 PM
Listbox on click WiReLaD Excel Programming 2 October 22nd 03 07:33 PM
Is refreshing listbox rowsource in listbox click event possible? Jeremy Gollehon[_2_] Excel Programming 4 September 25th 03 06:45 PM


All times are GMT +1. The time now is 01:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"