Form1.cs
Upload User: chinafred
Upload Date: 2007-08-14
Package Size: 10127k
Code Size: 3k
Category:

ADO-ODBC

Development Platform:

C#

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. namespace ch1_2
  8. {
  9. /// <summary>
  10. /// Form1 的摘要说明。
  11. /// </summary>
  12. public class Form1 : System.Windows.Forms.Form
  13. {
  14. private System.Windows.Forms.Button button1;
  15. private System.Windows.Forms.Button button2;
  16. /// <summary>
  17. /// 必需的设计器变量。
  18. /// </summary>
  19. private System.ComponentModel.Container components = null;
  20. public Form1()
  21. {
  22. //
  23. // Windows 窗体设计器支持所必需的
  24. //
  25. InitializeComponent();
  26. //
  27. // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
  28. //
  29. }
  30. /// <summary>
  31. /// 清理所有正在使用的资源。
  32. /// </summary>
  33. protected override void Dispose( bool disposing )
  34. {
  35. if( disposing )
  36. {
  37. if (components != null) 
  38. {
  39. components.Dispose();
  40. }
  41. }
  42. base.Dispose( disposing );
  43. }
  44. #region Windows Form Designer generated code
  45. /// <summary>
  46. /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  47. /// 此方法的内容。
  48. /// </summary>
  49. private void InitializeComponent()
  50. {
  51. this.button1 = new System.Windows.Forms.Button();
  52. this.button2 = new System.Windows.Forms.Button();
  53. this.SuspendLayout();
  54. // 
  55. // button1
  56. // 
  57. this.button1.Location = new System.Drawing.Point(56, 40);
  58. this.button1.Name = "button1";
  59. this.button1.Size = new System.Drawing.Size(184, 64);
  60. this.button1.TabIndex = 0;
  61. this.button1.Text = "让窗体始终显示在最前端";
  62. this.button1.Click += new System.EventHandler(this.button1_Click);
  63. // 
  64. // button2
  65. // 
  66. this.button2.Location = new System.Drawing.Point(56, 136);
  67. this.button2.Name = "button2";
  68. this.button2.Size = new System.Drawing.Size(184, 64);
  69. this.button2.TabIndex = 1;
  70. this.button2.Text = "让窗体恢复到正常";
  71. this.button2.Click += new System.EventHandler(this.button2_Click);
  72. // 
  73. // Form1
  74. // 
  75. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  76. this.ClientSize = new System.Drawing.Size(292, 273);
  77. this.Controls.AddRange(new System.Windows.Forms.Control[] {
  78.   this.button2,
  79.   this.button1});
  80. this.Name = "Form1";
  81. this.Text = "Form1";
  82. this.ResumeLayout(false);
  83. }
  84. #endregion
  85. /// <summary>
  86. /// 应用程序的主入口点。
  87. /// </summary>
  88. [STAThread]
  89. static void Main() 
  90. {
  91. Application.Run(new Form1());
  92. }
  93. private void button1_Click(object sender, System.EventArgs e)
  94. {
  95. //将窗体总是显示在最前端
  96. this.TopMost=true;
  97. }
  98. private void button2_Click(object sender, System.EventArgs e)
  99. {
  100. //窗体不会总显示在最前端
  101. this.TopMost=false;
  102. }
  103. }
  104. }