简体   繁体   中英

How do I make a Output Label on Visual Studio C#

I am new at using Visual Studio as well as C#. I'm having a hard time trying to figure out how to make a output label. Does anyone know how to do this?

What I've currently been doing is dragging the label control to the text box. Then, I would delete the text from the label but then it looks like it disappeared .

I think, this is what you want,

System.Windows.Forms.Label label1 = new System.Windows.Forms.Label();
label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
label1.Location = new System.Drawing.Point(34, 49);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(85, 23);
label1.TabIndex = 0;
label1.Text = "label1";
label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

first of all: this is broad question! I'll just answer according to my understanding.

Define the AutoSize of your label to False , then you can erase its text ( label1.Text = String.Empty ) without the label being seen as if it disappeared

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM