就是在InitializeComponent()中怎样实现?
解决方案 »
- C# 引用webservice System.Web.Services.Protocols.SoapException: 怎么解决
- C#有什么好的视频教程吗?
- c# textbox控件背景色不能设置为透明,但是我找了个代码,继承textbox属性 这样出现继承的控件, 并进行封装程序集,添加在工具箱中。没有学习过 求指
- 求助:控件DataGirdView中能不能提供掩码功能
- [新手]Window Mobile开发游戏,图片资源怎么处理?!
- 请高手帮忙!!!
- 请问,能在DataSet中设置标志位吗?如可以怎么设?
- 高难:有没有办法让下面两种链接都准确接受中文参数?
- 如何更新,添加记录
- 请问C# 多线程间如何传递消息方便些?
- 判断 e-mail 得问题
- windows画图,显示网格
我加了下面的代码后返回设计页面就有错误了
//设置窗体第一次出现的位置
Rectangle disk = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
int x = disk.Right - 186;
y = disk.Bottom - 255;
this.Location= new Point(x,y);
public Form1()
{
InitializeComponent();
//设置窗体第一次出现的位置
Rectangle disk = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
int x = disk.Right - 192;
int y = disk.Bottom - 280;
Form1.Location= new Point(x,y);
}
里应该就算是在构造函数里了
思路:
先算出屏幕长宽
然后算出窗口长宽
就可以得到窗口的坐标
然后在设置this.Location属性就OK了。
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
////设置窗体第一次出现的位置
Rectangle disk = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
int x = disk.Right - 192;
int y = disk.Bottom - 280;
Form1.Location= new Point(x,y);
}
在构造函数中:this.Location = new Point(x,y);//x,y来自已保存的配置参数
因为初始代码写到InitializeComponent();会丢代码?
通常都是写到public Form1()中
但是这样this.Location会出错,应该用什么替代this那?