我想让我在第一个文本框输入内容以后点击第二个按钮它就在第一个文本框类容里面加入/但是在二个文本框里面不加任何东西,如果我在第二个文本框里面写东西再点击第二个按钮那么就在第二个里面加/而第一个里面的文本框内容不变
[DllImport("user32.dll")]
public static extern int GetFocus();
IntPtr handle;
Control c;
private void button1_Click(object sender, EventArgs e)
{
c.Text += "。";
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.Focus();
handle = (IntPtr)GetFocus();
c = Control.FromHandle(handle);
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
textBox2.Focus();
handle = (IntPtr)GetFocus();
c = Control.FromHandle(handle);
}
private void textBox1_Click(object sender, EventArgs e)
{
textBox1.Focus();
handle = (IntPtr)GetFocus();
c = Control.FromHandle(handle);
}
private void textBox2_Click(object sender, EventArgs e)
{
textBox2.Focus();
handle = (IntPtr)GetFocus();
c = Control.FromHandle(handle);
}
在textbox的textchanged事件和click事件中设置焦点就好
根据输入内容添加/,是这样么
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0)
{
textBox1.Text += "/";
return;
}
if (textBox2.Text.Length > 0)
{
textBox2.Text += "/";
return;
}
}