adding objects at runtime

Reply

Join Date: Jan 2008
Posts: 16
Reputation: K-Dave is an unknown quantity at this point 
Solved Threads: 1
K-Dave K-Dave is offline Offline
Newbie Poster

adding objects at runtime

 
0
  #1
May 30th, 2008
How can i add objects such as buttons, labels or textboxes at runtime?
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: adding objects at runtime

 
0
  #2
May 30th, 2008
Hi
Example to adding control at runtime
  1. Option Explicit
  2. ' Declare object variable as CommandButton.
  3. Private WithEvents cmdObject As CommandButton
  4.  
  5. Private Sub Form_Load()
  6. Set cmdObject = Form1.Controls.Add("VB.CommandButton", "cmdOne")
  7. cmdObject.Visible = True
  8. cmdObject.Caption = "Dynamic CommandButton"
  9. End Sub
  10.  
  11. Private Sub cmdObject_Click()
  12. MsgBox "This is a dynamically added control"
  13. End Sub
Last edited by selvaganapathy; May 30th, 2008 at 9:33 am.
KSG
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: adding objects at runtime

 
0
  #3
May 30th, 2008
Yes u can, i think selvaganapathy was given the best answer
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC