大师,问一下:
private void button1_Click_1(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Owner = this; //把form2的父控件定位form1
form2.Location = new Point(30, 30);
form2.StartPosition = FormStartPosition.Manual; //弹出位置
form2.Show();
}弹出的form2窗口怎么不听使唤呢
确定了location,然后使用form2.StartPosition = FormStartPosition.Manual
弹出的form2窗口怎么不在指定位置呢
private void button1_Click_1(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Owner = this; //把form2的父控件定位form1
form2.Location = new Point(30, 30);
form2.StartPosition = FormStartPosition.Manual; //弹出位置
form2.Show();
}弹出的form2窗口怎么不听使唤呢
确定了location,然后使用form2.StartPosition = FormStartPosition.Manual
弹出的form2窗口怎么不在指定位置呢
form2.StartPosition = FormStartPosition.Manual; //弹出位置
对调下。
form2.Location = new Point(30, 30);这样呢?
private void button1_Click_1(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Owner = this; //把form2的父控件定位form1
form2.Location = new Point(30, 30);
form2.StartPosition = FormStartPosition.Manual; //弹出位置
form2.ShowDialog();
}
{
Form2 form2 = new Form2();
form2.Owner = this; //把form2的父控件定位form1
int x = (sender as Button).PointToScreen(new Point()).X;
int y = (sender as Button).PointToScreen(new Point()).Y; form2.StartPosition = FormStartPosition.Manual; //弹出位置
form2.Location = new Point( x, y);
form2.ShowDialog();
}
private void button1_Click_1(object sender, EventArgs e)
{
Form2 form2 = new Form2();
form2.Owner = this; //把form2的父控件定位form1
if (sender is Button)
{
int x = (sender as Button).PointToScreen(new Point()).X;
int y = (sender as Button).PointToScreen(new Point()).Y; form2.StartPosition = FormStartPosition.Manual; //弹出位置
form2.Location = new Point( x, y);
}
form2.ShowDialog();
}
form2.Left =30;
form2.Top =30;
form2.Show();
class1 中的 代码
private Point pointLocation;
public Point PointLocation;
{
get{return pointLocation;}set{pointLocation=value;}
}
form1 中的 代码
Class1 c1=eew Class1();
....
cl=new Point(30, 30);
....from2 中的代码
Class1 c1=eew Class1();
......
然后 在 form2 中的 Load 事件中 代码
this.Location =c1.pointLocation;就 行了 !