for (int cnt = 0; cnt<=4; cnt++) { TextBox txt = new TextBox(); txt.Location = new System.Drawing.Point(303, 324 + (cnt * 26)); txt.Name = "quickAdd" + cnt.ToString(); txt.Size = new System.Drawing.Size(102, 20); txt.Visible = true; txt.DoubleClick += (snd, arg) => textbox_DoubleClick(cnt.ToString()); tabPage7.Controls.Add(txt);} private void textbox_DoubleClick(object id) { MessageBox.Show(id.ToString());}