文本框之间内容的互相传递
1 namespace exchangeTest 2 { 3 public partial class exchange : Form 4 { 5 public exchange() 6 { 7 InitializeComponent(); 8 } 9 //往文本框二添加文本框一的内容 10 private void btnExchange_Click(object sender, EventArgs e) 11 { 12 text2.Text = text2.Text + text1.Text; 13 btnExchange.Enabled = false; 14 btnExchange0.Enabled = true; 15 btnExchange.Focus(); 16 } 17 //往文本框一添加文本框二的内容 18 private void btnExchange0_Click(object sender, EventArgs e) 19 { 20 text1.Text = text1.Text + text2.Text; 21 btnExchange0.Enabled = false; 22 btnExchange.Enabled = true; 23 btnExchange.Focus(); 24 } 25 //窗体装载,初始化控件,文本框获得输入焦点 26 private void Form1_Load(object sender, EventArgs e) 27 { 28 text1.Text = null; 29 text2.Text = null; 30 text1.Focus(); 31 } 32 } 33 }
时间: 2024-10-07 04:57:36