Form1.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:32k
源码类别:

C#编程

开发平台:

Others

  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 MenuSample
  8. {
  9. /// <summary>
  10. /// Summary description for Form1.
  11. /// </summary>
  12. public class mainFrm : System.Windows.Forms.Form
  13. {
  14.     private System.Windows.Forms.MainMenu mnuMain;
  15.     private System.Windows.Forms.MenuItem menuItem11;
  16.     private System.Windows.Forms.MenuItem menuItem12;
  17.     private System.Windows.Forms.MenuItem menuItem13;
  18.     private System.Windows.Forms.MenuItem menuItem14;
  19.     private System.Windows.Forms.MenuItem menuItem15;
  20.     private System.Windows.Forms.MenuItem menuItem16;
  21.     private System.Windows.Forms.MenuItem mnuFile;
  22.     private System.Windows.Forms.MenuItem mnuFileNew;
  23.     private System.Windows.Forms.MenuItem mnuFileOpen;
  24.     private System.Windows.Forms.MenuItem mnuFileClose;
  25.     private System.Windows.Forms.MenuItem mnuFileExit;
  26.     private System.Windows.Forms.MenuItem mnuEdit;
  27.     private System.Windows.Forms.MenuItem mnuEditCut;
  28.     private System.Windows.Forms.MenuItem mnuEditCopy;
  29.     private System.Windows.Forms.MenuItem mnuEditPaste;
  30.     private System.Windows.Forms.MenuItem mnuEditFind;
  31.     private System.Windows.Forms.MenuItem menuItem1;
  32.     private System.Windows.Forms.MenuItem menuItem2;
  33.     private System.Windows.Forms.ToolBar tbMain;
  34.     private System.Windows.Forms.ImageList ilToolbar;
  35.     private System.Windows.Forms.ToolBarButton tbtnNew;
  36.     private System.Windows.Forms.ToolBarButton tbtnOpen;
  37.     private System.Windows.Forms.ToolBarButton tbtnEdit;
  38.     private System.Windows.Forms.ToolBarButton tbtnIconLocation;
  39.     private System.Windows.Forms.ToolBarButton sep0;
  40.     private System.Windows.Forms.ToolBarButton sep1;
  41.     private System.Windows.Forms.ContextMenu cmnuEdit;
  42.     private System.Windows.Forms.MenuItem cmnuEditCut;
  43.     private System.Windows.Forms.MenuItem cmnuEditCopy;
  44.     private System.Windows.Forms.MenuItem cmnuEditPaste;
  45.     private System.Windows.Forms.ToolBarButton tbtnStyle;
  46.     private System.ComponentModel.IContainer components;
  47.     Font _fontBld;
  48.     private System.Windows.Forms.ErrorProvider errMain;
  49.     private System.Windows.Forms.Panel panel1;
  50.     private System.Windows.Forms.Label label2;
  51.     private System.Windows.Forms.Label label1;
  52.     private System.Windows.Forms.TextBox txtZipCode;
  53.     private System.Windows.Forms.TextBox txtAge;
  54.     private System.Windows.Forms.Label label3;
  55.     private System.Windows.Forms.HelpProvider helpProvider1;
  56.     private System.Windows.Forms.ComboBox comboBox1;
  57.     private System.Windows.Forms.StatusBar statusBar1;
  58.     private System.Windows.Forms.StatusBarPanel statusBarPanel1;
  59.     private System.Windows.Forms.StatusBarPanel statusBarPanel2;
  60.     private System.Windows.Forms.TabControl tabControl1;
  61.     private System.Windows.Forms.GroupBox grpToolbarIcon;
  62.     private System.Windows.Forms.RadioButton rbTop;
  63.     private System.Windows.Forms.RadioButton rbRight;
  64.     private System.Windows.Forms.TabPage tabPage1;
  65.     private System.Windows.Forms.TabPage tabPage2;
  66.     private System.Windows.Forms.Label label4;
  67.     private System.Windows.Forms.PictureBox pictureBox1;
  68.     private System.Windows.Forms.Button btnTest;
  69.     private System.Windows.Forms.CheckBox checkBox1;
  70.     private System.Windows.Forms.CheckBox checkBox2;
  71.     private System.Windows.Forms.DateTimePicker dateTimePicker1;
  72.     Font _fontReg;
  73. public mainFrm()
  74. {
  75. //
  76. // Required for Windows Form Designer support
  77. //
  78. InitializeComponent();
  79.       
  80. //
  81. // TODO: Add any constructor code after InitializeComponent call
  82. //
  83.       _fontBld = new Font("Arial", 8, FontStyle.Bold);
  84.       _fontReg = new Font("Arial", 8, FontStyle.Regular);
  85.       helpProvider1.SetHelpString(txtAge, "Enter an age that is less then 65");
  86.       helpProvider1.SetHelpString(txtZipCode, "Enter a 5 digit zip code");
  87. }
  88. /// <summary>
  89. /// Clean up any resources being used.
  90. /// </summary>
  91. protected override void Dispose( bool disposing )
  92. {
  93. if( disposing )
  94. {
  95. if (components != null) 
  96. {
  97. components.Dispose();
  98. }
  99. }
  100. base.Dispose( disposing );
  101. }
  102. #region Windows Form Designer generated code
  103. /// <summary>
  104. /// Required method for Designer support - do not modify
  105. /// the contents of this method with the code editor.
  106. /// </summary>
  107. private void InitializeComponent()
  108. {
  109.       this.components = new System.ComponentModel.Container();
  110.       System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(mainFrm));
  111.       this.mnuMain = new System.Windows.Forms.MainMenu();
  112.       this.mnuFile = new System.Windows.Forms.MenuItem();
  113.       this.mnuFileNew = new System.Windows.Forms.MenuItem();
  114.       this.mnuFileOpen = new System.Windows.Forms.MenuItem();
  115.       this.mnuFileClose = new System.Windows.Forms.MenuItem();
  116.       this.menuItem1 = new System.Windows.Forms.MenuItem();
  117.       this.mnuFileExit = new System.Windows.Forms.MenuItem();
  118.       this.mnuEdit = new System.Windows.Forms.MenuItem();
  119.       this.mnuEditCut = new System.Windows.Forms.MenuItem();
  120.       this.mnuEditCopy = new System.Windows.Forms.MenuItem();
  121.       this.mnuEditPaste = new System.Windows.Forms.MenuItem();
  122.       this.menuItem2 = new System.Windows.Forms.MenuItem();
  123.       this.mnuEditFind = new System.Windows.Forms.MenuItem();
  124.       this.menuItem11 = new System.Windows.Forms.MenuItem();
  125.       this.menuItem12 = new System.Windows.Forms.MenuItem();
  126.       this.menuItem13 = new System.Windows.Forms.MenuItem();
  127.       this.menuItem14 = new System.Windows.Forms.MenuItem();
  128.       this.menuItem15 = new System.Windows.Forms.MenuItem();
  129.       this.menuItem16 = new System.Windows.Forms.MenuItem();
  130.       this.tbMain = new System.Windows.Forms.ToolBar();
  131.       this.tbtnNew = new System.Windows.Forms.ToolBarButton();
  132.       this.tbtnOpen = new System.Windows.Forms.ToolBarButton();
  133.       this.sep0 = new System.Windows.Forms.ToolBarButton();
  134.       this.tbtnEdit = new System.Windows.Forms.ToolBarButton();
  135.       this.cmnuEdit = new System.Windows.Forms.ContextMenu();
  136.       this.cmnuEditCut = new System.Windows.Forms.MenuItem();
  137.       this.cmnuEditCopy = new System.Windows.Forms.MenuItem();
  138.       this.cmnuEditPaste = new System.Windows.Forms.MenuItem();
  139.       this.sep1 = new System.Windows.Forms.ToolBarButton();
  140.       this.tbtnIconLocation = new System.Windows.Forms.ToolBarButton();
  141.       this.tbtnStyle = new System.Windows.Forms.ToolBarButton();
  142.       this.ilToolbar = new System.Windows.Forms.ImageList(this.components);
  143.       this.errMain = new System.Windows.Forms.ErrorProvider();
  144.       this.panel1 = new System.Windows.Forms.Panel();
  145.       this.label2 = new System.Windows.Forms.Label();
  146.       this.label1 = new System.Windows.Forms.Label();
  147.       this.txtZipCode = new System.Windows.Forms.TextBox();
  148.       this.txtAge = new System.Windows.Forms.TextBox();
  149.       this.label3 = new System.Windows.Forms.Label();
  150.       this.helpProvider1 = new System.Windows.Forms.HelpProvider();
  151.       this.btnTest = new System.Windows.Forms.Button();
  152.       this.comboBox1 = new System.Windows.Forms.ComboBox();
  153.       this.statusBar1 = new System.Windows.Forms.StatusBar();
  154.       this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
  155.       this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
  156.       this.tabControl1 = new System.Windows.Forms.TabControl();
  157.       this.tabPage1 = new System.Windows.Forms.TabPage();
  158.       this.label4 = new System.Windows.Forms.Label();
  159.       this.tabPage2 = new System.Windows.Forms.TabPage();
  160.       this.pictureBox1 = new System.Windows.Forms.PictureBox();
  161.       this.grpToolbarIcon = new System.Windows.Forms.GroupBox();
  162.       this.rbTop = new System.Windows.Forms.RadioButton();
  163.       this.rbRight = new System.Windows.Forms.RadioButton();
  164.       this.checkBox1 = new System.Windows.Forms.CheckBox();
  165.       this.checkBox2 = new System.Windows.Forms.CheckBox();
  166.       this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
  167.       this.panel1.SuspendLayout();
  168.       ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
  169.       ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
  170.       this.tabControl1.SuspendLayout();
  171.       this.tabPage1.SuspendLayout();
  172.       this.tabPage2.SuspendLayout();
  173.       this.grpToolbarIcon.SuspendLayout();
  174.       this.SuspendLayout();
  175.       // 
  176.       // mnuMain
  177.       // 
  178.       this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  179.                                                                             this.mnuFile,
  180.                                                                             this.mnuEdit,
  181.                                                                             this.menuItem11});
  182.       // 
  183.       // mnuFile
  184.       // 
  185.       this.mnuFile.Index = 0;
  186.       this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  187.                                                                             this.mnuFileNew,
  188.                                                                             this.mnuFileOpen,
  189.                                                                             this.mnuFileClose,
  190.                                                                             this.menuItem1,
  191.                                                                             this.mnuFileExit});
  192.       this.mnuFile.Text = "&File";
  193.       // 
  194.       // mnuFileNew
  195.       // 
  196.       this.mnuFileNew.Index = 0;
  197.       this.mnuFileNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
  198.       this.mnuFileNew.Text = "&New";
  199.       // 
  200.       // mnuFileOpen
  201.       // 
  202.       this.mnuFileOpen.Index = 1;
  203.       this.mnuFileOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
  204.       this.mnuFileOpen.Text = "&Open";
  205.       // 
  206.       // mnuFileClose
  207.       // 
  208.       this.mnuFileClose.Index = 2;
  209.       this.mnuFileClose.Text = "&Close";
  210.       // 
  211.       // menuItem1
  212.       // 
  213.       this.menuItem1.Index = 3;
  214.       this.menuItem1.Text = "-";
  215.       // 
  216.       // mnuFileExit
  217.       // 
  218.       this.mnuFileExit.Index = 4;
  219.       this.mnuFileExit.Text = "E&xit";
  220.       this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click);
  221.       // 
  222.       // mnuEdit
  223.       // 
  224.       this.mnuEdit.Index = 1;
  225.       this.mnuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  226.                                                                             this.mnuEditCut,
  227.                                                                             this.mnuEditCopy,
  228.                                                                             this.mnuEditPaste,
  229.                                                                             this.menuItem2,
  230.                                                                             this.mnuEditFind});
  231.       this.mnuEdit.Text = "&Edit";
  232.       // 
  233.       // mnuEditCut
  234.       // 
  235.       this.mnuEditCut.Index = 0;
  236.       this.mnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
  237.       this.mnuEditCut.Text = "Cu&t";
  238.       // 
  239.       // mnuEditCopy
  240.       // 
  241.       this.mnuEditCopy.Index = 1;
  242.       this.mnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
  243.       this.mnuEditCopy.Text = "&Copy";
  244.       // 
  245.       // mnuEditPaste
  246.       // 
  247.       this.mnuEditPaste.Index = 2;
  248.       this.mnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
  249.       this.mnuEditPaste.Text = "&Paste";
  250.       // 
  251.       // menuItem2
  252.       // 
  253.       this.menuItem2.Index = 3;
  254.       this.menuItem2.Text = "-";
  255.       // 
  256.       // mnuEditFind
  257.       // 
  258.       this.mnuEditFind.Index = 4;
  259.       this.mnuEditFind.Shortcut = System.Windows.Forms.Shortcut.CtrlF;
  260.       this.mnuEditFind.Text = "&Find";
  261.       // 
  262.       // menuItem11
  263.       // 
  264.       this.menuItem11.Index = 2;
  265.       this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  266.                                                                                this.menuItem12,
  267.                                                                                this.menuItem13,
  268.                                                                                this.menuItem14});
  269.       this.menuItem11.Text = "&App";
  270.       // 
  271.       // menuItem12
  272.       // 
  273.       this.menuItem12.Index = 0;
  274.       this.menuItem12.Text = "Do Something";
  275.       // 
  276.       // menuItem13
  277.       // 
  278.       this.menuItem13.Checked = true;
  279.       this.menuItem13.Index = 1;
  280.       this.menuItem13.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftC;
  281.       this.menuItem13.Text = "Is Checked";
  282.       // 
  283.       // menuItem14
  284.       // 
  285.       this.menuItem14.Index = 2;
  286.       this.menuItem14.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  287.                                                                                this.menuItem15,
  288.                                                                                this.menuItem16});
  289.       this.menuItem14.Text = "Sub Menu";
  290.       // 
  291.       // menuItem15
  292.       // 
  293.       this.menuItem15.Index = 0;
  294.       this.menuItem15.Text = "Sub Sub Menu";
  295.       // 
  296.       // menuItem16
  297.       // 
  298.       this.menuItem16.Index = 1;
  299.       this.menuItem16.Text = "Another Sub Menu";
  300.       // 
  301.       // tbMain
  302.       // 
  303.       this.tbMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
  304.                                                                               this.tbtnNew,
  305.                                                                               this.tbtnOpen,
  306.                                                                               this.sep0,
  307.                                                                               this.tbtnEdit,
  308.                                                                               this.sep1,
  309.                                                                               this.tbtnIconLocation,
  310.                                                                               this.tbtnStyle});
  311.       this.tbMain.DropDownArrows = true;
  312.       this.tbMain.ImageList = this.ilToolbar;
  313.       this.tbMain.Location = new System.Drawing.Point(0, 0);
  314.       this.tbMain.Name = "tbMain";
  315.       this.tbMain.ShowToolTips = true;
  316.       this.tbMain.Size = new System.Drawing.Size(488, 28);
  317.       this.tbMain.TabIndex = 0;
  318.       this.tbMain.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
  319.       this.tbMain.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbMain_ButtonClick);
  320.       // 
  321.       // tbtnNew
  322.       // 
  323.       this.tbtnNew.ImageIndex = 0;
  324.       this.tbtnNew.Text = "New";
  325.       this.tbtnNew.ToolTipText = "Create new document";
  326.       // 
  327.       // tbtnOpen
  328.       // 
  329.       this.tbtnOpen.ImageIndex = 1;
  330.       this.tbtnOpen.Text = "Open";
  331.       this.tbtnOpen.ToolTipText = "Open existing document";
  332.       // 
  333.       // sep0
  334.       // 
  335.       this.sep0.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
  336.       // 
  337.       // tbtnEdit
  338.       // 
  339.       this.tbtnEdit.DropDownMenu = this.cmnuEdit;
  340.       this.tbtnEdit.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
  341.       this.tbtnEdit.Text = "Edit";
  342.       this.tbtnEdit.ToolTipText = "Cop, Cut and Paste";
  343.       // 
  344.       // cmnuEdit
  345.       // 
  346.       this.cmnuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  347.                                                                              this.cmnuEditCut,
  348.                                                                              this.cmnuEditCopy,
  349.                                                                              this.cmnuEditPaste});
  350.       // 
  351.       // cmnuEditCut
  352.       // 
  353.       this.cmnuEditCut.Index = 0;
  354.       this.cmnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
  355.       this.cmnuEditCut.Text = "Cut";
  356.       // 
  357.       // cmnuEditCopy
  358.       // 
  359.       this.cmnuEditCopy.Index = 1;
  360.       this.cmnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
  361.       this.cmnuEditCopy.Text = "Copy";
  362.       // 
  363.       // cmnuEditPaste
  364.       // 
  365.       this.cmnuEditPaste.Index = 2;
  366.       this.cmnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
  367.       this.cmnuEditPaste.Text = "Paste";
  368.       // 
  369.       // sep1
  370.       // 
  371.       this.sep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
  372.       // 
  373.       // tbtnIconLocation
  374.       // 
  375.       this.tbtnIconLocation.ImageIndex = 2;
  376.       this.tbtnIconLocation.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
  377.       this.tbtnIconLocation.Text = "Icon";
  378.       this.tbtnIconLocation.ToolTipText = "Icon is beside or beneath the text";
  379.       // 
  380.       // tbtnStyle
  381.       // 
  382.       this.tbtnStyle.ImageIndex = 4;
  383.       this.tbtnStyle.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
  384.       this.tbtnStyle.Text = "Style";
  385.       this.tbtnStyle.ToolTipText = "Changes the style of the toolbar.";
  386.       // 
  387.       // ilToolbar
  388.       // 
  389.       this.ilToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
  390.       this.ilToolbar.ImageSize = new System.Drawing.Size(16, 16);
  391.       this.ilToolbar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilToolbar.ImageStream")));
  392.       this.ilToolbar.TransparentColor = System.Drawing.Color.Transparent;
  393.       // 
  394.       // errMain
  395.       // 
  396.       this.errMain.ContainerControl = this;
  397.       // 
  398.       // panel1
  399.       // 
  400.       this.panel1.Controls.Add(this.label2);
  401.       this.panel1.Controls.Add(this.label1);
  402.       this.panel1.Controls.Add(this.txtZipCode);
  403.       this.panel1.Controls.Add(this.txtAge);
  404.       this.panel1.Location = new System.Drawing.Point(224, 88);
  405.       this.panel1.Name = "panel1";
  406.       this.panel1.Size = new System.Drawing.Size(224, 88);
  407.       this.panel1.TabIndex = 9;
  408.       // 
  409.       // label2
  410.       // 
  411.       this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System;
  412.       this.label2.Location = new System.Drawing.Point(14, 45);
  413.       this.label2.Name = "label2";
  414.       this.label2.Size = new System.Drawing.Size(64, 23);
  415.       this.label2.TabIndex = 12;
  416.       this.label2.Text = "Zip Code";
  417.       this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  418.       this.label2.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
  419.       this.label2.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
  420.       // 
  421.       // label1
  422.       // 
  423.       this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
  424.       this.label1.Location = new System.Drawing.Point(14, 21);
  425.       this.label1.Name = "label1";
  426.       this.label1.Size = new System.Drawing.Size(64, 23);
  427.       this.label1.TabIndex = 11;
  428.       this.label1.Text = "Age:";
  429.       this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  430.       this.label1.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
  431.       this.label1.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
  432.       // 
  433.       // txtZipCode
  434.       // 
  435.       this.txtZipCode.Location = new System.Drawing.Point(86, 45);
  436.       this.txtZipCode.Name = "txtZipCode";
  437.       this.txtZipCode.TabIndex = 10;
  438.       this.txtZipCode.Text = "";
  439.       this.txtZipCode.Validating += new System.ComponentModel.CancelEventHandler(this.txtZipCode_Validating);
  440.       // 
  441.       // txtAge
  442.       // 
  443.       this.txtAge.Location = new System.Drawing.Point(86, 21);
  444.       this.txtAge.Name = "txtAge";
  445.       this.txtAge.TabIndex = 9;
  446.       this.txtAge.Text = "";
  447.       this.txtAge.Validating += new System.ComponentModel.CancelEventHandler(this.txtAge_Validating);
  448.       // 
  449.       // label3
  450.       // 
  451.       this.label3.Location = new System.Drawing.Point(224, 64);
  452.       this.label3.Name = "label3";
  453.       this.label3.Size = new System.Drawing.Size(128, 16);
  454.       this.label3.TabIndex = 10;
  455.       this.label3.Text = "Error Provider Example";
  456.       // 
  457.       // btnTest
  458.       // 
  459.       this.btnTest.FlatStyle = System.Windows.Forms.FlatStyle.System;
  460.       this.btnTest.Location = new System.Drawing.Point(224, 208);
  461.       this.btnTest.Name = "btnTest";
  462.       this.btnTest.TabIndex = 11;
  463.       this.btnTest.Text = "Sample";
  464.       this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
  465.       // 
  466.       // comboBox1
  467.       // 
  468.       this.comboBox1.Items.AddRange(new object[] {
  469.                                                    "Item 1",
  470.                                                    "Item 2",
  471.                                                    "Item 3",
  472.                                                    "Item 4"});
  473.       this.comboBox1.Location = new System.Drawing.Point(224, 256);
  474.       this.comboBox1.Name = "comboBox1";
  475.       this.comboBox1.Size = new System.Drawing.Size(121, 21);
  476.       this.comboBox1.TabIndex = 12;
  477.       this.comboBox1.Text = "comboBox1";
  478.       // 
  479.       // statusBar1
  480.       // 
  481.       this.statusBar1.Location = new System.Drawing.Point(0, 544);
  482.       this.statusBar1.Name = "statusBar1";
  483.       this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
  484.                                                                                   this.statusBarPanel1,
  485.                                                                                   this.statusBarPanel2});
  486.       this.statusBar1.ShowPanels = true;
  487.       this.statusBar1.Size = new System.Drawing.Size(488, 24);
  488.       this.statusBar1.TabIndex = 13;
  489.       this.statusBar1.Text = "statusBar1";
  490.       // 
  491.       // statusBarPanel1
  492.       // 
  493.       this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
  494.       this.statusBarPanel1.Text = "This is the first panel";
  495.       this.statusBarPanel1.Width = 118;
  496.       // 
  497.       // statusBarPanel2
  498.       // 
  499.       this.statusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
  500.       this.statusBarPanel2.Text = "This is the second panel";
  501.       this.statusBarPanel2.Width = 354;
  502.       // 
  503.       // tabControl1
  504.       // 
  505.       this.tabControl1.Controls.Add(this.tabPage1);
  506.       this.tabControl1.Controls.Add(this.tabPage2);
  507.       this.tabControl1.Location = new System.Drawing.Point(24, 304);
  508.       this.tabControl1.Name = "tabControl1";
  509.       this.tabControl1.SelectedIndex = 0;
  510.       this.tabControl1.Size = new System.Drawing.Size(424, 224);
  511.       this.tabControl1.TabIndex = 14;
  512.       // 
  513.       // tabPage1
  514.       // 
  515.       this.tabPage1.Controls.Add(this.dateTimePicker1);
  516.       this.tabPage1.Controls.Add(this.label4);
  517.       this.tabPage1.Location = new System.Drawing.Point(4, 22);
  518.       this.tabPage1.Name = "tabPage1";
  519.       this.tabPage1.Size = new System.Drawing.Size(416, 198);
  520.       this.tabPage1.TabIndex = 0;
  521.       this.tabPage1.Text = "Tab Page 1";
  522.       // 
  523.       // label4
  524.       // 
  525.       this.label4.Location = new System.Drawing.Point(24, 16);
  526.       this.label4.Name = "label4";
  527.       this.label4.Size = new System.Drawing.Size(152, 23);
  528.       this.label4.TabIndex = 0;
  529.       this.label4.Text = "This is a label on a tab page";
  530.       // 
  531.       // tabPage2
  532.       // 
  533.       this.tabPage2.Controls.Add(this.pictureBox1);
  534.       this.tabPage2.Location = new System.Drawing.Point(4, 22);
  535.       this.tabPage2.Name = "tabPage2";
  536.       this.tabPage2.Size = new System.Drawing.Size(416, 198);
  537.       this.tabPage2.TabIndex = 1;
  538.       this.tabPage2.Text = "Another Tab Page";
  539.       // 
  540.       // pictureBox1
  541.       // 
  542.       this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
  543.       this.pictureBox1.Location = new System.Drawing.Point(40, 16);
  544.       this.pictureBox1.Name = "pictureBox1";
  545.       this.pictureBox1.Size = new System.Drawing.Size(352, 168);
  546.       this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
  547.       this.pictureBox1.TabIndex = 0;
  548.       this.pictureBox1.TabStop = false;
  549.       // 
  550.       // grpToolbarIcon
  551.       // 
  552.       this.grpToolbarIcon.Controls.Add(this.rbTop);
  553.       this.grpToolbarIcon.Controls.Add(this.rbRight);
  554.       this.grpToolbarIcon.FlatStyle = System.Windows.Forms.FlatStyle.System;
  555.       this.grpToolbarIcon.Location = new System.Drawing.Point(32, 80);
  556.       this.grpToolbarIcon.Name = "grpToolbarIcon";
  557.       this.grpToolbarIcon.Size = new System.Drawing.Size(144, 88);
  558.       this.grpToolbarIcon.TabIndex = 15;
  559.       this.grpToolbarIcon.TabStop = false;
  560.       this.grpToolbarIcon.Text = "Location";
  561.       // 
  562.       // rbTop
  563.       // 
  564.       this.rbTop.Location = new System.Drawing.Point(16, 56);
  565.       this.rbTop.Name = "rbTop";
  566.       this.rbTop.TabIndex = 1;
  567.       this.rbTop.Text = "Top";
  568.       this.rbTop.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
  569.       this.rbTop.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
  570.       this.rbTop.CheckedChanged += new System.EventHandler(this.rbTop_CheckedChanged);
  571.       // 
  572.       // rbRight
  573.       // 
  574.       this.rbRight.Checked = true;
  575.       this.rbRight.Location = new System.Drawing.Point(16, 24);
  576.       this.rbRight.Name = "rbRight";
  577.       this.rbRight.TabIndex = 0;
  578.       this.rbRight.TabStop = true;
  579.       this.rbRight.Text = "Right";
  580.       this.rbRight.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
  581.       this.rbRight.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
  582.       this.rbRight.CheckedChanged += new System.EventHandler(this.rbRight_CheckedChanged);
  583.       // 
  584.       // checkBox1
  585.       // 
  586.       this.checkBox1.Location = new System.Drawing.Point(32, 200);
  587.       this.checkBox1.Name = "checkBox1";
  588.       this.checkBox1.TabIndex = 16;
  589.       this.checkBox1.Text = "checkBox1";
  590.       this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
  591.       // 
  592.       // checkBox2
  593.       // 
  594.       this.checkBox2.Location = new System.Drawing.Point(32, 224);
  595.       this.checkBox2.Name = "checkBox2";
  596.       this.checkBox2.TabIndex = 17;
  597.       this.checkBox2.Text = "checkBox2";
  598.       this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
  599.       // 
  600.       // dateTimePicker1
  601.       // 
  602.       this.dateTimePicker1.Location = new System.Drawing.Point(24, 48);
  603.       this.dateTimePicker1.Name = "dateTimePicker1";
  604.       this.dateTimePicker1.TabIndex = 1;
  605.       this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
  606.       // 
  607.       // mainFrm
  608.       // 
  609.       this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  610.       this.ClientSize = new System.Drawing.Size(488, 568);
  611.       this.Controls.Add(this.checkBox2);
  612.       this.Controls.Add(this.checkBox1);
  613.       this.Controls.Add(this.grpToolbarIcon);
  614.       this.Controls.Add(this.tabControl1);
  615.       this.Controls.Add(this.statusBar1);
  616.       this.Controls.Add(this.comboBox1);
  617.       this.Controls.Add(this.btnTest);
  618.       this.Controls.Add(this.label3);
  619.       this.Controls.Add(this.panel1);
  620.       this.Controls.Add(this.tbMain);
  621.       this.Menu = this.mnuMain;
  622.       this.Name = "mainFrm";
  623.       this.Text = "Menu and Toolbars";
  624.       this.panel1.ResumeLayout(false);
  625.       ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
  626.       ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
  627.       this.tabControl1.ResumeLayout(false);
  628.       this.tabPage1.ResumeLayout(false);
  629.       this.tabPage2.ResumeLayout(false);
  630.       this.grpToolbarIcon.ResumeLayout(false);
  631.       this.ResumeLayout(false);
  632.     }
  633. #endregion
  634. /// <summary>
  635. /// The main entry point for the application.
  636. /// </summary>
  637. [STAThread]
  638. static void Main() 
  639. {
  640.       //Uncomment the following two lines to see what EnableVisualStyles looks like
  641.       //Requires Windows XP or Windows 2003.
  642. //      Application.EnableVisualStyles();
  643. //      Application.DoEvents();
  644. Application.Run(new mainFrm());
  645. }
  646.     //event handler for the exit menu.
  647.     private void mnuFileExit_Click(object sender, System.EventArgs e)
  648.     {
  649.       Application.Exit();
  650.     }
  651.     /// <summary>
  652.     /// This is the button clicked event handler for the toolbar buttons.
  653.     /// All of the buttons on the toolbar use the same event. the button that was 
  654.     /// clicked is passed in the ToolBarButtonClickEventArgs paramter. Therefore in the handler
  655.     /// you must differentiate which button raised the event in a switch statement.
  656.     /// This example uses the text property of the button.
  657.     /// </summary>
  658.     /// <param name="sender">Object raising event</param>
  659.     /// <param name="e"></param>
  660.     private void tbMain_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
  661.     {
  662.     
  663.       switch(e.Button.Text)
  664.       {
  665.         
  666.         case "New"  :
  667.         {
  668.           MessageBox.Show("The New toolbar button was selected.");
  669.           break;
  670.         }
  671.         case "Open"  :
  672.         {
  673.           MessageBox.Show(e.Button.Text + " toolbar button was selected.");
  674.           break;
  675.         }
  676.         case "Icon" :
  677.         {
  678.           if(e.Button.Pushed)
  679.             e.Button.ImageIndex = 3;
  680.           else
  681.             e.Button.ImageIndex = 2;
  682.           if(tbMain.TextAlign == ToolBarTextAlign.Right)
  683.             tbMain.TextAlign = ToolBarTextAlign.Underneath;
  684.           else
  685.             tbMain.TextAlign = ToolBarTextAlign.Right;
  686.           break;
  687.         }
  688.         case "Style"  :
  689.         {
  690.           if(e.Button.Pushed)
  691.             tbMain.Appearance = ToolBarAppearance.Flat;
  692.           else
  693.             tbMain.Appearance = ToolBarAppearance.Normal;
  694.           break;
  695.         }
  696.       }
  697.           
  698.     }
  699.     //Handles the MouseEnter event on a control that supports the Font property.
  700.     private void ControlMouseEnter(object sender, EventArgs e)
  701.     {
  702.       ((Control)sender).Font = _fontBld;
  703.     }
  704.     
  705.     //Handles the MouseLeave event on controls that supports the Font property
  706.     private void ControlMouseLeave(object sender, EventArgs e)
  707.     {
  708.       ((Control)sender).Font = _fontReg;
  709.     }
  710.     /// <summary>
  711.     /// The Validing event for the txtAge text box. This is the ErrorProvider example.
  712.     /// </summary>
  713.     /// <param name="sender"></param>
  714.     /// <param name="e"></param>
  715.     private void txtAge_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  716.     {
  717.       if(txtAge.TextLength > 0 && Convert.ToInt32(txtAge.Text) > 65)
  718.       {
  719.         errMain.SetIconAlignment((Control)sender, ErrorIconAlignment.MiddleRight);
  720.         errMain.SetError((Control)sender, "Value must be less then 65.");
  721.         e.Cancel = true;
  722.       }
  723.       else
  724.       {
  725.         errMain.SetError((Control)sender, "");
  726.       }
  727.     }
  728.     /// <summary>
  729.     /// Validating event for txtZipCode to support the ErrorProvider example
  730.     /// </summary>
  731.     /// <param name="sender"></param>
  732.     /// <param name="e"></param>
  733.     private void txtZipCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
  734.     {
  735.       if(txtZipCode.Text.Length != 5)
  736.       {
  737.         errMain.SetIconAlignment((Control)sender, ErrorIconAlignment.MiddleRight);
  738.         errMain.SetError((Control)sender, "Must be 5 charactors..");
  739.         e.Cancel = true;
  740.       }
  741.       else
  742.       {
  743.         errMain.SetError((Control)sender, "");
  744.       }
  745.     }
  746.     /// <summary>
  747.     /// CheckedChanged event handler for the rbRight radio button
  748.     /// </summary>
  749.     /// <param name="sender"></param>
  750.     /// <param name="e"></param>
  751.     
  752.     private void rbRight_CheckedChanged(object sender, System.EventArgs e)
  753.     {
  754.       MessageBox.Show(((RadioButton)sender).Name + " has changed.");
  755.     }
  756.     /// <summary>
  757.     /// ChaeckedChanged event handler for the rbTop Radio Button
  758.     /// </summary>
  759.     /// <param name="sender"></param>
  760.     /// <param name="e"></param>
  761.     private void rbTop_CheckedChanged(object sender, System.EventArgs e)
  762.     {
  763.       MessageBox.Show(((RadioButton)sender).Name + " has changed.");
  764.     }
  765.     
  766.     /// <summary>
  767.     /// Button1 Click event handler.
  768.     /// </summary>
  769.     /// <param name="sender"></param>
  770.     /// <param name="e"></param>
  771.     private void btnTest_Click(object sender, System.EventArgs e)
  772.     {
  773.       MessageBox.Show(((Button)sender).Name + " was clicked.");
  774.     }
  775.     private void checkBox_CheckedChanged(object sender, System.EventArgs e)
  776.     {
  777.       MessageBox.Show(((CheckBox)sender).Name + " changed");
  778.     }
  779.     private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
  780.     {
  781.       label4.Text = dateTimePicker1.Text;
  782.     }
  783. }
  784. }