目前Form1
有textBox1
,Form1
有StartPosition = CenterScreen
,textBox1
有textBox1_MouseClick
代码textBox1_MouseClick
private void textBox1_MouseClick(object sender, MouseEventArgs e)
{
Form2 frm2 = new Form2();
frm2.ShowDialog();
}
在Form2
也有StartPosition = CenterScreen
当我点击textBox1
将Form2
覆盖的textBox1
。
我想要发生的是它不会覆盖textBox1
何时Form2
显示,它应该textBox1
像工具提示一样显示在它的下方。我怎样才能做到这一点?
更新代码:
private void textBox1_MouseClick(object sender, MouseEventArgs e)
{
Form2 frm2 = new Form2();
frm2.StartPosition = FormStartPosition.Manual;
frm2.Location = new Point(this.Location.X + textBox1.Location.X, this.Location.Y + textBox1.Location.Y);
frm2.ShowDialog();
}
private void textBox2_MouseClick(object sender, MouseEventArgs e)
{
Form2 frm2 = new Form2();
frm2.StartPosition = FormStartPosition.Manual;
frm2.Location = new Point(this.Location.X + textBox2.Location.X, this.Location.Y + textBox2.Location.Y);
frm2.ShowDialog();
}
没有点击文本框:
点击文本框1:
点击文本框2: