public void Addlbl()
{
Label lbl;
Seat seat;
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 4;j++ )
{
lbl = new Label();
lbl.Name = "lbl"+(j+1).ToString()+"_"+(i+1).ToString();
lbl.BackColor = Color.Yellow;
lbl.AutoSize = false;
lbl.Size = new Size(50,25);
lbl.Text = (j+1).ToString()+"_"+(i+1).ToString();
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Location = new Point(60+(i*90),50+(j*90));
lbl.Click += new EventHandler(lbl_click);
tabSchedule.Controls.Add(lbl);
seat = new Seat();
seat.SeatName = (j+1).ToString()+"_"+(i+1).ToString();
seat.SeatColor = Color.Yellow;
ciname.Seats.Add(seat.SeatName,seat);
}
}
}
void lbl_Click(object sender, EventArgs e)
{
想在方法里面弹出你所点击标签的TEXT
}
{
Label lbl;
Seat seat;
for (int i = 0; i < 7; i++)
{
for (int j = 0; j < 4;j++ )
{
lbl = new Label();
lbl.Name = "lbl"+(j+1).ToString()+"_"+(i+1).ToString();
lbl.BackColor = Color.Yellow;
lbl.AutoSize = false;
lbl.Size = new Size(50,25);
lbl.Text = (j+1).ToString()+"_"+(i+1).ToString();
lbl.TextAlign = ContentAlignment.MiddleCenter;
lbl.Location = new Point(60+(i*90),50+(j*90));
lbl.Click += new EventHandler(lbl_click);
tabSchedule.Controls.Add(lbl);
seat = new Seat();
seat.SeatName = (j+1).ToString()+"_"+(i+1).ToString();
seat.SeatColor = Color.Yellow;
ciname.Seats.Add(seat.SeatName,seat);
}
}
}
void lbl_Click(object sender, EventArgs e)
{
想在方法里面弹出你所点击标签的TEXT
}
{
MessageBox.Show(((Label)sender).Text);
}