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

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