CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2008
    Posts
    3

    Make copy of label

    Hi


    I have 3 designed labels on forms with different colors and shapes.

    I would like to know if in a file .cs make several copies of 3 pre designed labels on Forms. My purpose is to define and make visible only the necessary labels.

    Example:

    pseudo - code

    pre designed label, label 2 and label 3

    make n copies of these 3 labels

    change location of each created labels

    end of pseudo - code

    Thanks

  2. #2
    Join Date
    Jan 2007
    Posts
    491

    Re: Make copy of label

    Here's an example how to create N labels on runtime:
    Code:
    const int N = 5;
    Label[] labelA = new Label[N];
    ...
    for(int i=0;i<N;i++)
    {
       labelA[i] = new Label();
       labelA[i].Name = "LabelA" + i;
       labelA[i].Size = label1.Size;
       labelA[i].Location = new Location(WHATEVER...);
       labelA[i].Color = label1.Color;
       ...
       etc.
    
       this.Controls.Add(labelA[i]);
    }

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

Featured