你可以用Form的location属性设置。
解决方案 »
- webBrowser 怎么去实现
- 能不能在Crystal report X1 里面建立视图
- 用MySQL Connector Net 1.0.7连MYSQL的时候,最后做安装包该怎么处理
- 轻松获取20分
- 小散分嘍,要分来接!!!可追加分!!!
- c#中的线程控制!
- C# asp.net高效分页类. 基于此类想写一个简单的分层框架,有利于美工与程序员配合.欢迎一起探讨
- 缓存的问题
- 怎么把界面上的数据写入EXCAL表!要考虑分页情况
- C#split怎么按回车符截取字符数组
- ####### C# in a nutshell a desktop quick reference ######誰看了這本書,學c#這本書好不好(初學者)
- IL是解释运行的吗?
openForm=new OpenForm();
openForm.Location=new System.Drawing.Point(btn.Location.X,btn.Location.Y+20);
openForm.Show();
我这样做是没有达到我上述要求,
为什么?
单击第一次它出现在左上方,以后每单击打开
它会沿,他的X,Y坐标会增加即往,bottom,right方向移动
到屏幕中间后有会退至第一次的位置
{
private OpenForm openForm;//另一窗体
public MainForm()
{
......
}
private void Buttons_Click(object sender,EvengArgs e)
{
Button btn=(Button)sender;
openForm=new OpenForm();
openForm.Location=new System.Drawing.Point(tn.Location.X,btn.Location.Y+20);
openForm.Show();
}
}
{
form2=new Form2 ();
form2.StartPosition=FormStartPosition.Manual ;
form2.Location =new System.Drawing.Point(0,200);
form2.Show ();
}
即可
openForm.Location=new System.Drawing.Point(tn.Location.X,btn.Location.Y+20);試試用:
openForm.Left=btn.Left;
openForm.Top=btn.Top+20;
System.Windows.Forms.Control parentControl=button.Parent;
System.Drawing.Point position = new System.Drawing.Point(0,0);
while (!(parentControl is System.Windows.Forms.Form))
{
position.X += parentControl.Location.X;
position.Y += parentControl.Location.Y;
parentControl = parentControl.Parent;
}
position.X += button.Location.X;
position.Y += button.Location.Y+button.Height;
openForm.Location=position;
{
form2=new Form1 ();
form2.StartPosition=FormStartPosition.Manual ;
//横坐标
int X=this.Location.X +this.button1 .Location .X ;
//纵坐标
int Y=this.Location .Y+this.button1 .Location .Y
+this.button1 .Size .Height+30;
form2.Location =new System.Drawing.Point(X,Y);
form2.Show ();
}
不断点按钮,效果是不错的
坐标中的数字30是form2的上面显示标题部分(蓝色条)的高度