Hi
i have 10 textbox in mu win form
iwant insert data from this 10 textbox to one textbox
how do it?
thanks
How to insert data from 10 text box to one text box?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Micke BlomqvistRank #1,660 · 923 reputationPosted Feb 9, 2011, 10:25 PM EST
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(txtBox1.Text);
sb.Append(txtBox2.Text);
sb.Append(txtBox3.Text);
sb.Append(txtBox4.Text);
sb.Append(txtBox5.Text);
sb.Append(txtBox6.Text);
sb.Append(txtBox7.Text);
sb.Append(txtBox8.Text);
sb.Append(txtBox9.Text);
sb.Append(txtBox10.Text);
txtBox_all_together.Text = sb.ToString();
Amit ChoudharyRank #145 · 15.8K reputationPosted Feb 10, 2011, 12:51 AM EST
Little enhancement to the above code give by Micke.
foreach(Control ctl in Form.Controls)
{
if(ctl is TextBox)
{
sb.Append(((TextBox)ctl).Text);
}
}
txtBox_all_together.Text = sb.ToString();
Hope it helps you.
Please mark the "Do you like this post" if it helps you.