Thread: How to place controls?

  1. #1
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

    How to place controls?

    OK, you place everything with the designer. Now I just want to place a create a TextBox on the Form. How do I do this? I just do:
    Code:
    TextBox t = new TextBox();
    t.Location = new Point(10, 10);
    this.controls.Add(t);
    But it doesn't appear on the Form. What more do I need?

  2. #2
    Registered User
    Join Date
    Aug 2008
    Posts
    188
    t.Size = new Size(300, 20);

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    "controls" has a capital C.
    Where exactly are you calling this? Works fine for me, you probably put it somewhere which isn't called.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Lol. I typed TextBox. I wanted to type PictureBox. In which case I wasn't setting the BackColor so it didn't appear because it probably gave a default color which was the same with the Form. Stupid mistake.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. confused about adding controls to main window
    By terracota in forum Windows Programming
    Replies: 4
    Last Post: 11-24-2004, 12:35 PM
  2. Controls
    By osal in forum Windows Programming
    Replies: 7
    Last Post: 06-11-2004, 10:38 AM
  3. Subclassing controls
    By filler_bunny in forum Windows Programming
    Replies: 3
    Last Post: 04-28-2004, 05:43 PM
  4. I need help disabling Keyboard and Mouse input on Edit controls
    By Templario in forum Windows Programming
    Replies: 4
    Last Post: 01-07-2003, 12:59 AM
  5. How to place controls on a window
    By samudrala_99 in forum Windows Programming
    Replies: 5
    Last Post: 12-06-2002, 04:56 PM