Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Runtime control creation.....

Runtime control creation.....

Scheduled Pinned Locked Moved Visual Basic
help
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    Xandip
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • X Xandip

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      X 1 Reply Last reply
      0
      • C Christian Graus

        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 )

        X Offline
        X Offline
        Xandip
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • X Xandip

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            M Offline
            M Offline
            manni_n
            wrote on last edited by
            #5

            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

            D 1 Reply Last reply
            0
            • M manni_n

              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

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              M 1 Reply Last reply
              0
              • D Dave Kreskowiak

                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

                M Offline
                M Offline
                manni_n
                wrote on last edited by
                #7

                obviously u must be knowing dave... this is code is not for you. yeah by mistake i replied your post...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups