teardrop
شنبه 22 اسفند 1388, 15:28 عصر
چطوری میشه لیستی از کنترل ها به صورت پویا درست کرد و به هر کدام بتوان در رویداد مخصوص به خودش کد نوشت.
مثال:
n تا جعبه متن درست کنیم وبه سومی در رویداد Keypress پیغامی بدهد.
حالتی در درست کردن کنترلها به صورت آرایه ای در VB6
M.YasPro
شنبه 22 اسفند 1388, 16:24 عصر
سلام
TextBox text;
private List<Label> AddControl()
{
List<Label> lblList = new List<Label>();
for (int i = 0; i < 10; i++)
{
text = new TextBox();
this.text.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.text.Name = "textBox" + i.ToString();
this.text.Text = "textBox" + i.ToString();
if (i == 3)
this.text.KeyPress += new KeyPressEventHandler(textBox);
this.Controls.Add(text);
}
return lblList;
}
private void textBox(object sender, KeyPressEventArgs e)
{
MessageBox.Show(e.KeyChar.ToString());
}
vBulletin® v4.2.5, Copyright ©2000-1403, Jelsoft Enterprises Ltd.