Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
i have to create a number of objects. they could be forms or any object really, but i want to know is how do i create a new object when a user clicks a button? the user could click the button many times, creating many objects, and i dont want to limit the user by only declaring a set number of objects
Posted

As far as I know, all objects are created at runtime.

I don't believe there is a piece of software that can manipulate data before it is run.

 

Ok, past the sarcasm, Im going to assume 1. you know what you are talking about and 2. you don't know the type of the object you want to instantiate...

 

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemactivatorclasscreateinstancetopic.asp

Posted

Here's an example of creating a form from scratch and adding a textbox to the form

 

       Dim frm As New Form
       frm.Name = "frmCreated"
       frm.Text = "Created Form"

       Dim tb As New TextBox
       tb.Name = "tbTest"

       frm.Controls.Add(tb)
       frm.Show()

 

Of course you can set other properties of the form and textbox such as size, location, borderstyle, etc.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...