PDA

View Full Version : سوال: ظاهر شدن Label با زدن کلید button



sahel65
یک شنبه 11 اردیبهشت 1390, 12:34 عصر
سلام؛
میخوام وقتی کاربر روی button کلیک کرد ، یه label ظاهر بشه؛


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

Label LBL;

string title = "hello";

private void button1_Click(object sender, EventArgs e)
{
LBL = new Label();
LBL.Text = title;
LBL.Location = new Point(100, 120);
LBL.Parent = Parent;
LBL = new LBL(10, 50, title, this);
LBL.Show();
}
}
}

با این دستورات ولی ظاهر نمیشه!
میشه راهنماییم کنید؟

flash118
یک شنبه 11 اردیبهشت 1390, 13:07 عصر
با سلام
ئوست عزیز آقای hojat1 روش شما هم روش خوبی هست ولی اونی که مد نظر دوستمون هست نیست ایشون می خواهند در زمان اجرا ایجاد کنن و نشون بدن نه در زمان طراحی خاصیت visable رو غیر فعال کنن و هنگام نمایش فعال کنن !
اما کد که برای دوستمون آماده شده به شرح زیر هست:

private void button1_Click(object sender, EventArgs e)
{
Label newlab1 = new Label();

newlab1.Text = "FLASH118";
newlab1.Location = new Point(50, 50);
this.Controls.Add(newlab1);

}

موفق باشید

sabloger
یک شنبه 11 اردیبهشت 1390, 17:43 عصر
سلام دوست عزیز

Label label3 = new Label();

label3.AutoSize = true;
label3.Location = new System.Drawing.Point(100, 100);
label3.Name = "lbltext";
label3.Size = new System.Drawing.Size(35, 13);
label3.Text = "text";
label3.Visible = true;
label3.Parent = this;