我写了一个类,类中有个方法是将窗体初始化:代码如下
public void Form_Initialize(int FormWidth, int FormHeight)
{
int ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
int ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
this.Left = ScreenWidth / 2 - this.Width / 2;
this.Top = ScreenHeight / 2 - this.Height / 2;
}
但是编译的时候总提示我“Class1' does not contain a definition for 'Left'”
我怀疑是使用this的缘故,请问该如何修改啊?
public void Form_Initialize(int FormWidth, int FormHeight)
{
int ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
int ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Width;
this.Left = ScreenWidth / 2 - this.Width / 2;
this.Top = ScreenHeight / 2 - this.Height / 2;
}
但是编译的时候总提示我“Class1' does not contain a definition for 'Left'”
我怀疑是使用this的缘故,请问该如何修改啊?
看样子好像不是窗体
用这个
然后把函数中所有的this都换成form