winform,如何让控件出现在form中间

winform,如何让控件出现在form中间。最好form放大后,这个控件还是在中间

int gLeft = this.Width / 2 - lable1.Width / 2;
int gTop = this.Height / 2 - lable1.Height / 2;
控件.Location = new Point(gLeft, gTop);

第一是模式显示,既showDialog().这种显示只需要设置StartPosition=CenterPostion.用代码如下:

From f2=new Form();

f2.StartPosition = FormStartPosition.CenterParent;

f2.ShowDialog()

第二种是非模式显示:这样只能用手动去控制他的位置了。代码如下:

From f2=new Form();

f2.Left = this.Left + (this.Width - f2.Width) / 2;
f2.Top = this.Top + (this.Top - f2.Top) / 2;
f2.Show();