Runtime control creation.....
-
I need some help regarding the creation of control instances during runtime of an application. For eg: I have a tabcontrol with only one tab, and a textbox in that single tab. When I click a 'NEW' button, a new tab must be created in the control AND along with that I want a new text box in the latest tab. I am using VB Thnx for any help...
The name is Sandeep
-
I need some help regarding the creation of control instances during runtime of an application. For eg: I have a tabcontrol with only one tab, and a textbox in that single tab. When I click a 'NEW' button, a new tab must be created in the control AND along with that I want a new text box in the latest tab. I am using VB Thnx for any help...
The name is Sandeep
The textbox needs to be added to the tab control's controls collection, and the tab page is added to the tab controls collection of tab pages.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
The textbox needs to be added to the tab control's controls collection, and the tab page is added to the tab controls collection of tab pages.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hello Christian, Thnx for your suggestion. But can you explain it? I understood what you said, but still didnt get how to do it. I hope you have not forgotten that I'm using VB.
The name is Sandeep
Add the control you created to the forms
Controls
collection:Dim tb As New TextBox tb.Location = ... tb.Size = ... Me.Controls.Add(tb)
For the tab page, you add it to the TabControl's
Controls
collection.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Add the control you created to the forms
Controls
collection:Dim tb As New TextBox tb.Location = ... tb.Size = ... Me.Controls.Add(tb)
For the tab page, you add it to the TabControl's
Controls
collection.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007Adding an control at runtime The following routine adds the Email label and associated text box at run time. Private Sub AddEmailAddress() Dim txtEmail As New TextBox Dim lblEmail As New Label ' Set the desired properties txtEmail.Top = txtAddress.Top + txtAddress.Height + 10 txtEmail.Left = txtAddress.Left lblEmail.Text = "Email" lblEmail.Location = New Point(lblAddress.Location.X, _ txtEmail.Location.Y) ' Add to the collection txtAddress.Controls.Add(txtEmail) txtAddress.Controls.Add(lblEmail) End Sub The above is adopted from MSDN. When you are creating controls at runtime you need to add event handlers in runtime also.. Read the following topic.. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv\_vstechart/html/controlarrays.asp
-
Adding an control at runtime The following routine adds the Email label and associated text box at run time. Private Sub AddEmailAddress() Dim txtEmail As New TextBox Dim lblEmail As New Label ' Set the desired properties txtEmail.Top = txtAddress.Top + txtAddress.Height + 10 txtEmail.Left = txtAddress.Left lblEmail.Text = "Email" lblEmail.Location = New Point(lblAddress.Location.X, _ txtEmail.Location.Y) ' Add to the collection txtAddress.Controls.Add(txtEmail) txtAddress.Controls.Add(lblEmail) End Sub The above is adopted from MSDN. When you are creating controls at runtime you need to add event handlers in runtime also.. Read the following topic.. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv\_vstechart/html/controlarrays.asp
Why are you telling me this? Tell the original poster! That way, he'll get a message that you replied instead of me. I already know how to do this stuff...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
Why are you telling me this? Tell the original poster! That way, he'll get a message that you replied instead of me. I already know how to do this stuff...
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007