Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default ADD LISTBOX, COMBOBOX, LABEL IN THE SAME USERFORM

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?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default ADD LISTBOX, COMBOBOX, LABEL IN THE SAME USERFORM

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default ADD LISTBOX, COMBOBOX, LABEL IN THE SAME USERFORM

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?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default ADD LISTBOX, COMBOBOX, LABEL IN THE SAME USERFORM

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?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default ADD LISTBOX, COMBOBOX, LABEL IN THE SAME USERFORM

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
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
fill userform textbox from userform listbox clik event GregJG[_21_] Excel Programming 3 December 7th 08 04:47 PM
View Listbox items in the Label Incidental Excel Programming 3 July 17th 08 01:51 PM
label on top of a listbox CG Rosén Excel Programming 2 October 2nd 07 07:27 PM
userform listbox cannot get listbox.value to transfer back to main sub [email protected] Excel Programming 1 May 17th 06 09:44 PM
comboBox vs Listbox Steve Excel Programming 2 March 14th 06 12:23 AM


All times are GMT +1. The time now is 02:39 AM.

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

About Us

"It's about Microsoft Excel"