Add Multi GroupBox and show messgebox (gb.text) for every groupbox Always messgebox last groupbox

  • Thread starter Thread starter ee406621
  • Start date Start date
E

ee406621

Guest
GroupBox GB ;

int num = 0;



for (int i = 1; i < 5; i++)
{
num += 1;

GB = new GroupBox();
GB.Name ="GB" + i;
GB.Text = "GB" + i;
GB.Size= new Size( 964, 40);
GB.Click += new EventHandler(test);
int LocationX = Convert.ToInt32(GB.Location.X);
Locationy = Locationy + 120;
GB.Location = new Point(LocationX, Locationy);
this.Controls.Add(GB);
}


protected void test(object sender, EventArgs e)
{
MessageBox.Show(GB.Text);
}

Continue reading...
 
Back
Top