首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于初始化窗体,该怎么解决

2012-03-06 
关于初始化窗体我写了一个类,类中有个方法是将窗体初始化:代码如下publicvoidForm_Initialize(intFormWidt

关于初始化窗体
我写了一个类,类中有个方法是将窗体初始化:代码如下
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(Form form , int FormWidth, int FormHeight)
用这个
然后把函数中所有的this都换成form

热点排行