Thread: Dynamic labels??

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    Dynamic labels??

    Hello:
    this is the idea:I have 1 button on the form, and when I click the button very time, there would be some random number of labels appear on the form.
    So, I was trying to show only 1 label, inside the button events, I created:

    System.Windows.Forms.Label label1;
    label1 = new System.Windows.Forms.Label();
    label1.Location = new System.Drawing.Point(72, 120);
    label1.Name = "label1";
    label1.Size = new System.Drawing.Size(112, 32);
    label1.TabIndex = 1;
    label1.Text = "label1";


    it could run,but I could't see the label when i clicked the button,
    what is the problem or is that possible to do like this??
    Don't laugh at me,I am just a SuperNewbie.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    You need to add the label to the form's control list:

    this.Controls.AddRange( new System.Windows.Forms.Control[] {label1});


    where this is the form.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    haha,thanx, this is such kind of cool thing.
    thanx again
    Don't laugh at me,I am just a SuperNewbie.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Storing labels in a list?
    By arcaine01 in forum C# Programming
    Replies: 2
    Last Post: 05-10-2008, 11:10 PM
  2. dynamic array/vector help
    By Cpro in forum C++ Programming
    Replies: 8
    Last Post: 04-05-2008, 03:30 PM
  3. Identify dynamic IP address of network device
    By BobS0327 in forum Tech Board
    Replies: 2
    Last Post: 02-21-2006, 01:49 PM
  4. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM
  5. Dynamic Labels again!!
    By SuperNewbie in forum C# Programming
    Replies: 3
    Last Post: 07-11-2002, 12:36 AM