[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4324
  • Last Modified:

C# How to create a label in run time, and place it on a particular panel

How to create a label in run time, and place it on a particular panel
0
amielDorel
Asked:
amielDorel
  • 2
1 Solution
 
felipecslCommented:
Label myLabel = new Label();
myLabel.Text = "enter text here";
Panel myPanel = new Panel();
myPanel.Controls.Add(myPanel);

You can also control other label properties as location, dock, anchor, etc.
0
 
felipecslCommented:
Please correct the last line of code above.
instead of myPanel.Controls.Add(myPanel); put myPanel.Controls.Add(myLabel );

If the Panel hasn't been added to your Form yet, you can also do it by myForm.Controls.Add(myPanel);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now