Results 1 to 8 of 8

Thread: create text boxes at runtime

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2001
    Posts
    283

    create text boxes at runtime

    how can i create a textbox with a set position and size on a form at runtime?

    thanks,
    marvin

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Very easy. It should be something like this:
    VB Code:
    1. Dim mytextbox as New TextBox
    2. mytextbox.Size=New System.Drawing.Size(80, 16)
    3. mytextbox.Location = New System.Drawing.Point(184, 4)
    4. ....' any other property goes here. [b]dont forget[/b] to add this textbox to form or whatever container you need.
    5. Form1.Controls.Add(mytextbox)
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Out of curiosity, what is the advantage of creating controls at runtime?
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    From what i have learned from gurus here, i can say when you know what you are doing and it's planned , its better to add them at desgin time.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  5. #5
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    But isn't it a lot more work to add them all like that instead of just slapping them on the form? And wouldn't that slow down your program if you had like a thousand controls to load?
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

  6. #6
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Originally posted by The Phoenix
    But isn't it a lot more work to add them all like that instead of just slapping them on the form? And wouldn't that slow down your program if you had like a thousand controls to load?
    Yes, more work, and more chance of run time errors.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Usually , people do that they should have the Runtime Controls Manager part done (or whatever they call it) . This manager handles everything for runtime created controls from naming or setting some properties to the diffictult part which controlling events . I've seen one manager but I can't remember where . It's jut huge and it scared me really . Like 4 classes and I believe the possiblity of araisng errers is just zero . Most often , you need that when your app has a lot of controls while it's running , it eats up more memory and sends you an error message saying 'Out of Memory' . So , you tends to build that at runtime . Plus the exe would be farily smaller and faster .

  8. #8
    Addicted Member The Phoenix's Avatar
    Join Date
    Aug 2003
    Location
    With my wife
    Posts
    142
    Ah. Thank you for the explanation Pirate.
    Take my love
    Take my land
    Take me where I cannot stand
    I don't care, I'm still free
    You can't take the sky from me...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width