WinForm Program Development
------------------------------Main Page----------------------------------
BaseForm.cs base class, for deriving child windows
Login.cs Login for Login window
MainForm.cs home page, System home page
LoginOut.cs logoff for log-in logoff window
Page folder, other directory where startups are located
------------------------------Entrance Procedure----------------------------------
Static Class Program
{
public static Form mainform = null;
<summary>
The main entry point for the application.
</summary>
[STAThread]
static void Main ()
{
Application.enablevisualstyles ();
Application.setcompatibletextrenderingdefault (FALSE);
Application.Run (New Login ());
if (mainform! = null)
{
Application.Run (MainForm);
}
}
}
------------------------------------------------------------------
Page Jump
Instantiate the main screen
Program.mainform = new MainForm ();
Close the login screen
This. Close ();
---------------------------Create a base class---------------------------------------
Namespace Biogasprojectclient.page
{
Partial class BaseForm
{
<summary>
Required designer variable.
</summary>
Private System.ComponentModel.IContainer components = null;
<summary>
Clean up any resources being used.
</summary>
<param name= "disposing" >true if managed resources should be disposed; Otherwise, false.</param>
protected override void Dispose (bool disposing)
{
if (disposing && (components = null))
{
Components. Dispose ();
}
Base. Dispose (disposing);
}
#region Windows Form Designer generated code
<summary>
Required method for Designer support-do not modify
The contents of this method with the Code editor.
</summary>
private void InitializeComponent ()
{
This. SuspendLayout ();
//
BaseForm
//
This. Autoscaledimensions = new System.Drawing.SizeF (6F, 12F);
This. AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
This. ClientSize = new System.Drawing.Size (702, 337);
This. Name = "BaseForm";
This. ResumeLayout (FALSE);
}
#endregion
}
}
---------------------------the WebBrowser control---------------------------------------
1. Call URL
THIS.WEBBROWSER1.URL = new System.Uri ("http://127.0.0.1", System.UriKind.Absolute);
2. Disable Right-click
this.webBrowser1.IsWebBrowserContextMenuEnabled = false;
---------------------------the DockPanel control to display the page---------------------------------------
Subpage sp = new subpage (); Child page
DockPanel Display subpage page
This.dpmain the name of the control for DockPanel
This.sp.Show (This.dpmain, WeifenLuo.WinFormsUI.Docking.DockState.Document);
---------------------------Click to pop up the new page---------------------------------------
private void Menu_click (object sender, EventArgs e) {
Subpage sp = new subpage ();
Sp. ShowDialog (); Pop up a new page
}
WinForm Program Development