PC Review


Reply
Thread Tools Rate Thread

Double click item in Listbox to select item and close Listbox

 
 
=?Utf-8?B?R3VzRXZhbnM=?=
Guest
Posts: n/a
 
      18th Jul 2007
Have a large complicated VBA Project in which the first item after it starts
is displaying a Listbox with 30 items (single select). Now the user must
select the item and click the OK Button (it works). But from a windows GUI
viewpoint they should be able to just double click the desired item and have
it work the same as select and click OK. I have looked all through the
Properties Window but see nothing to make it work. Just want to make it work
like a real Windows App.
XP Pro - Excel 2003

Any help (even if can't be done) would be appreciated.
--
Gus Evans
 
Reply With Quote
 
 
 
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      18th Jul 2007
> Have a large complicated VBA Project in which the first item after it
> starts
> is displaying a Listbox with 30 items (single select). Now the user must
> select the item and click the OK Button (it works). But from a windows
> GUI
> viewpoint they should be able to just double click the desired item and
> have
> it work the same as select and click OK. I have looked all through the
> Properties Window but see nothing to make it work. Just want to make it
> work
> like a real Windows App.
> XP Pro - Excel 2003


Assuming your OK button is an ActiveX control named CommandButton1 for this
example (user your actual control's name, of course), just put this one line
in the ListBox's DoubleClick event...

CommandButton1_Click

and double clicking an item will do the same as selecting an item and
clicking the CommandButton.


Rick

 
Reply With Quote
 
 
 
 
=?Utf-8?B?R3VzRXZhbnM=?=
Guest
Posts: n/a
 
      18th Jul 2007
Great - worked like a charm!
--
Gus Evans


"Rick Rothstein (MVP - VB)" wrote:

> > Have a large complicated VBA Project in which the first item after it
> > starts
> > is displaying a Listbox with 30 items (single select). Now the user must
> > select the item and click the OK Button (it works). But from a windows
> > GUI
> > viewpoint they should be able to just double click the desired item and
> > have
> > it work the same as select and click OK. I have looked all through the
> > Properties Window but see nothing to make it work. Just want to make it
> > work
> > like a real Windows App.
> > XP Pro - Excel 2003

>
> Assuming your OK button is an ActiveX control named CommandButton1 for this
> example (user your actual control's name, of course), just put this one line
> in the ListBox's DoubleClick event...
>
> CommandButton1_Click
>
> and double clicking an item will do the same as selecting an item and
> clicking the CommandButton.
>
>
> Rick
>
>

 
Reply With Quote
 
Incidental
Guest
Posts: n/a
 
      19th Jul 2007
Hi Gus

You could do it using code like that listed below

Option Explicit
Dim LstSelection As String

Private Sub CommandButton1_Click()
Call DoYourThingHere
End Sub

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Call DoYourThingHere
End Sub

Sub DoYourThingHere()
LstSelection = ListBox1.Value
MsgBox LstSelection
ListBox1.Visible = False
End Sub

hope this helps

S

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse double-click to select listbox item and run userform Lemi Microsoft Excel Programming 3 19th Jul 2009 03:01 PM
Double click right mouse not a double click Freddy Windows XP Internet Explorer 5 23rd Jan 2008 11:12 AM
Double click event invoked when no double click has occurred Michael Matuszak Microsoft Access Forms 0 6th Aug 2004 03:51 PM
Close taskbar item with double-click? Episode3WillSuck Windows XP Help 1 2nd Jun 2004 11:31 AM
No Double-Click event fired for a ListView when I double click. active Microsoft VB .NET 1 26th Nov 2003 06:44 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:48 PM.