PC Review


Reply
Thread Tools Rate Thread

ADD LISTBOX, COMBOBOX, LABEL IN THE SAME USERFORM

 
 
Eddie_SP
Guest
Posts: n/a
 
      12th Aug 2009
In a multipage control, after clicking on a button, can I add a Listbox (or
any other object) without closing this multipage?


Example:

If Me.CommandButton1.Value = True Then
Listbox.Add
With Listbox
Width = X
Height = Y
Top = YY
Left = RR
End With


So... Is that possible?
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      12th Aug 2009
I've always found it much, much easier to add the controls in design mode. Then
use code to toggle the visibility. (You could change the position if you needed
to.)

Eddie_SP wrote:
>
> In a multipage control, after clicking on a button, can I add a Listbox (or
> any other object) without closing this multipage?
>
> Example:
>
> If Me.CommandButton1.Value = True Then
> Listbox.Add
> With Listbox
> Width = X
> Height = Y
> Top = YY
> Left = RR
> End With
>
> So... Is that possible?


--

Dave Peterson
 
Reply With Quote
 
john
Guest
Posts: n/a
 
      12th Aug 2009
must confess never added a control on the fly before but had a quick play &
managed to get following to work. Maybe give you some ideas to develop
further.

Private Sub CommandButton1_Click()
Dim MyPage As MSforms.Page
Dim MyListBox As MSforms.ListBox


Set MyPage = MultiPage1.Pages(0)

Set MyListBox = MyPage.Controls.Add("Forms.ListBox.1")

With MyListBox

.Top = 10
.Left = 20
.Height = 50

End With

End Sub
--
jb


"Eddie_SP" wrote:

> In a multipage control, after clicking on a button, can I add a Listbox (or
> any other object) without closing this multipage?
>
>
> Example:
>
> If Me.CommandButton1.Value = True Then
> Listbox.Add
> With Listbox
> Width = X
> Height = Y
> Top = YY
> Left = RR
> End With
>
>
> So... Is that possible?

 
Reply With Quote
 
Eddie_SP
Guest
Posts: n/a
 
      12th Aug 2009
Wow John, it started working...
I can go on from here now !

Thank you sir !

=)

Thank you Dave.

"john" wrote:

> must confess never added a control on the fly before but had a quick play &
> managed to get following to work. Maybe give you some ideas to develop
> further.
>
> Private Sub CommandButton1_Click()
> Dim MyPage As MSforms.Page
> Dim MyListBox As MSforms.ListBox
>
>
> Set MyPage = MultiPage1.Pages(0)
>
> Set MyListBox = MyPage.Controls.Add("Forms.ListBox.1")
>
> With MyListBox
>
> .Top = 10
> .Left = 20
> .Height = 50
>
> End With
>
> End Sub
> --
> jb
>
>
> "Eddie_SP" wrote:
>
> > In a multipage control, after clicking on a button, can I add a Listbox (or
> > any other object) without closing this multipage?
> >
> >
> > Example:
> >
> > If Me.CommandButton1.Value = True Then
> > Listbox.Add
> > With Listbox
> > Width = X
> > Height = Y
> > Top = YY
> > Left = RR
> > End With
> >
> >
> > So... Is that possible?

 
Reply With Quote
 
john
Guest
Posts: n/a
 
      12th Aug 2009
you are welcome.

if you want to add the control to a new page

just replace this line:

Set MyPage = MultiPage1.Pages(0)

with this

Set MyPage = MultiPage1.Pages.Add("Page" & MultiPage1.Pages.count + 1)

good luck.
--
jb


"Eddie_SP" wrote:

> Wow John, it started working...
> I can go on from here now !
>
> Thank you sir !
>
> =)
>
> Thank you Dave.
>
> "john" wrote:
>
> > must confess never added a control on the fly before but had a quick play &
> > managed to get following to work. Maybe give you some ideas to develop
> > further.
> >
> > Private Sub CommandButton1_Click()
> > Dim MyPage As MSforms.Page
> > Dim MyListBox As MSforms.ListBox
> >
> >
> > Set MyPage = MultiPage1.Pages(0)
> >
> > Set MyListBox = MyPage.Controls.Add("Forms.ListBox.1")
> >
> > With MyListBox
> >
> > .Top = 10
> > .Left = 20
> > .Height = 50
> >
> > End With
> >
> > End Sub
> > --
> > jb
> >
> >
> > "Eddie_SP" wrote:
> >
> > > In a multipage control, after clicking on a button, can I add a Listbox (or
> > > any other object) without closing this multipage?
> > >
> > >
> > > Example:
> > >
> > > If Me.CommandButton1.Value = True Then
> > > Listbox.Add
> > > With Listbox
> > > Width = X
> > > Height = Y
> > > Top = YY
> > > Left = RR
> > > End With
> > >
> > >
> > > So... Is that possible?

 
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
fill userform textbox from userform listbox clik event GregJG Microsoft Excel Programming 1 7th Dec 2008 02:05 PM
userform listbox cannot get listbox.value to transfer back to main sub malosky2@msn.com Microsoft Excel Programming 1 17th May 2006 09:44 PM
Re: Bug: Combobox.dropdown = True during Form.Load event handler causes listbox to be disabled, even though combobox is Enabled. Herfried K. Wagner [MVP] Microsoft Dot NET Framework Forms 0 12th Feb 2004 10:00 PM
Bug: Combobox.dropdown = True during Form.New() causes listbox to be disabled, even though combobox is Enabled. =?Utf-8?B?UmF0a2lsZXk=?= Microsoft Dot NET Framework Forms 1 12th Feb 2004 09:58 PM
Bug: Combobox.dropdown = True during Form.Load event handler causes listbox to be disabled, even though combobox is Enabled. =?Utf-8?B?UmF0a2lsZXk=?= Microsoft Dot NET Framework 0 12th Feb 2004 07:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:55 PM.