Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how can i create dynamic lable in C#.net windows application ??

Posted on 2011-02-16
3
Medium Priority
?
360 Views
Last Modified: 2012-05-11
i want to create dynamic lable in my C#.net windows application, not drag and drop from visual studio toolbox but creating it from code behind (in cs file) , but how can i do this ??
0
Comment
Question by:Parth48
3 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 34908437
Create a new label; then add it to the appropriate control's Controls collection:
Label newLabel = new Label();

newLabel.Text = "Hello World!";

this.placeHolder1.Controls.Add(newLabel);

Open in new window

0
 
LVL 9

Expert Comment

by:rawinnlnx9
ID: 34908458
This is a pretty concise example. Replace the textbox with label controls and you should be on your way. Please note that properties are a little bit different but this will explain how you do it.

http://support.microsoft.com/kb/317794

This search string will give you additional links that are right on so long as you stay in the first 5 or 10 hits.

http://www.google.com/#hl=en&sugexp=ool30&xhr=t&q=C%23+asp+create+controls+at+runtime&cp=0&pf=p&sclient=psy&site=&source=hp&aq=f&aqi=&aql=&oq=C%23+asp+create+controls+at+runtime&pbx=1&bav=on.1,or.&fp=5e2b21bd614e0a97

0
 

Expert Comment

by:binh_vu54321
ID: 34931434
You can do that: drag a Label named lbTest. And Find lbTest in the design file. And copy that part of code into where you want to create the label. Remember to rename the control.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question