从上次关闭窗口的位置启动窗口
public partial class Frm_Main : Form { public Frm_Main() { InitializeComponent(); } private void Frm_Main_Load(object sender, EventArgs e) { RegistryKey myReg1, myReg2;//声明注册表对象 myReg1 = Registry.CurrentUser;//获取当前用户注册表项 try { myReg2 = myReg1.CreateSubKey("Software\\MySoft");//在注册表项中创建子项 this.Location = new Point(Convert.ToInt16(myReg2.GetValue("1")), Convert.ToInt16(myReg2.GetValue("2")));//设置窗体的显示位置 } catch { } } private void Frm_Main_FormClosed(object sender, FormClosedEventArgs e) { RegistryKey myReg1, myReg2;//声明注册表对象 myReg1 = Registry.CurrentUser;//获取当前用户注册表项 myReg2 = myReg1.CreateSubKey("Software\\MySoft");//在注册表项中创建子项 try { myReg2.SetValue("1", this.Location.X.ToString());//将窗体关闭位置的x坐标写入注册表 myReg2.SetValue("2", this.Location.Y.ToString());//将窗体关闭位置的y坐标写入注册表 } catch { } } }
浮躁的人容易问:我到底该学什么;----别问,学就对了; 浮躁的人容易问:JS有钱途吗;----建议你去抢银行; 浮躁的人容易说:我要中文版!我英文不行!----不行?学呀! 浮躁的人分两种:只观望而不学的人;只学而不坚持的人; 浮躁的人永远不是一个高手。