18 November 2012

TextBox Value into ComboBox

 private void MulityTextBoxes(int cnt)
        {
            txt = new TextBox[cnt];
            for (int i = 0; i < cnt; i++)
            {
                txt[i] = new TextBox();
                txt[i].Name = "TextBox" + i.ToString();
                txt[i].Tag = i.ToString();
                txt[i].Size = new Size(50, 20);
                txt[i].Location = new System.Drawing.Point(10, 20 + (i * 28));
                txt[i].Leave += new System.EventHandler(txt_Leave);
                panel1.Controls.Add(txt[i]);        
            }
        }

 private void txt_Leave(object sender, EventArgs e)
        {
            TextBox picbox = (TextBox)sender;
            int PicboxIndex = Convert.ToInt32(picbox.Tag);
            comboBox1.Items.Remove("");
            comboBox1.Items.Add(txt[PicboxIndex].Text); 
        }

No comments: