1。程序退出时弹出一个对话框让用户确认 (记录上一次程序运行时窗口的位置、大小)

    添加相应 Form 的 Closing Closed 事件处理方法

Windows Forms Programming In C# 读书笔记 - 第二章 Formsprivate void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
Windows Forms Programming In C# 读书笔记 - 第二章 Forms            DialogResult res 
= MessageBox.Show("您确认要退出?" , "退出" ,  MessageBoxButtons.YesNo);
Windows Forms Programming In C# 读书笔记 - 第二章 Forms            e.Cancel 
= ( res == DialogResult.No );
Windows Forms Programming In C# 读书笔记 - 第二章 Forms        }

Windows Forms Programming In C# 读书笔记 - 第二章 Forms
Windows Forms Programming In C# 读书笔记 - 第二章 Forms        
private void Form1_Closed(object sender, System.EventArgs e)
{
Windows Forms Programming In C# 读书笔记 - 第二章 Forms            MessageBox.Show(
"谢谢使用");
Windows Forms Programming In C# 读书笔记 - 第二章 Forms        }

    备注:在 Closing 或者 Closed 事件处理方法中,可以用来记录Form的相关情况,便于以后使用(比如当前窗口位置、大小等)


2。Form中各种的 Size 和 Location

Windows Forms Programming In C# 读书笔记 - 第二章 Forms
ClientSize 不包括标题栏、边框等
DesktopLocation 不包括任务栏



--------------------------------------------------------------------------------------------------------------

ps:今天是元宵节,外面炮声隆隆(爆竹):)。Windows Forms Programming in C# (作者Chris Sells,Addison Wesley出版社,2003.8。),我看的是英文的chm电子版,这也是我第一次认真的 一本电子书,感到这本书确实不错,文笔流畅清晰易懂,例子和解说也都很精当。(看这本书是为完成这学期的 面向对象技术 这门课的作业作准备,估计到时候大部分人C++,少部分Java,用C#应该显得比较特别^_^)

相关文章:

  • 2022-12-23
  • 2021-09-01
  • 2021-06-25
  • 2021-09-27
  • 2021-07-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
猜你喜欢
  • 2021-06-22
  • 2021-08-19
  • 2021-07-28
  • 2021-06-12
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案