ControlSampleForm.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:33k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data;
- namespace MenuSample
- {
- /// <summary>
- /// Summary description for Form1.
- /// </summary>
- public class mainFrm : System.Windows.Forms.Form
- {
- private System.Windows.Forms.MainMenu mnuMain;
- private System.Windows.Forms.MenuItem menuItem11;
- private System.Windows.Forms.MenuItem menuItem12;
- private System.Windows.Forms.MenuItem menuItem13;
- private System.Windows.Forms.MenuItem menuItem14;
- private System.Windows.Forms.MenuItem menuItem15;
- private System.Windows.Forms.MenuItem menuItem16;
- private System.Windows.Forms.MenuItem mnuFile;
- private System.Windows.Forms.MenuItem mnuFileNew;
- private System.Windows.Forms.MenuItem mnuFileOpen;
- private System.Windows.Forms.MenuItem mnuFileClose;
- private System.Windows.Forms.MenuItem mnuFileExit;
- private System.Windows.Forms.MenuItem mnuEdit;
- private System.Windows.Forms.MenuItem mnuEditCut;
- private System.Windows.Forms.MenuItem mnuEditCopy;
- private System.Windows.Forms.MenuItem mnuEditPaste;
- private System.Windows.Forms.MenuItem mnuEditFind;
- private System.Windows.Forms.MenuItem menuItem1;
- private System.Windows.Forms.MenuItem menuItem2;
- private System.Windows.Forms.ToolBar tbMain;
- private System.Windows.Forms.ImageList ilToolbar;
- private System.Windows.Forms.ToolBarButton tbtnNew;
- private System.Windows.Forms.ToolBarButton tbtnOpen;
- private System.Windows.Forms.ToolBarButton tbtnEdit;
- private System.Windows.Forms.ToolBarButton tbtnIconLocation;
- private System.Windows.Forms.ToolBarButton sep0;
- private System.Windows.Forms.ToolBarButton sep1;
- private System.Windows.Forms.ContextMenu cmnuEdit;
- private System.Windows.Forms.MenuItem cmnuEditCut;
- private System.Windows.Forms.MenuItem cmnuEditCopy;
- private System.Windows.Forms.MenuItem cmnuEditPaste;
- private System.Windows.Forms.ToolBarButton tbtnStyle;
- private System.ComponentModel.IContainer components;
- Font _fontBld;
- private System.Windows.Forms.ErrorProvider errMain;
- private System.Windows.Forms.Panel panel1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox txtZipCode;
- private System.Windows.Forms.TextBox txtAge;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.HelpProvider helpProvider1;
- private System.Windows.Forms.ComboBox comboBox1;
- private System.Windows.Forms.StatusBar statusBar1;
- private System.Windows.Forms.StatusBarPanel statusBarPanel1;
- private System.Windows.Forms.StatusBarPanel statusBarPanel2;
- private System.Windows.Forms.TabControl tabControl1;
- private System.Windows.Forms.GroupBox grpToolbarIcon;
- private System.Windows.Forms.RadioButton rbTop;
- private System.Windows.Forms.RadioButton rbRight;
- private System.Windows.Forms.TabPage tabPage1;
- private System.Windows.Forms.TabPage tabPage2;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.PictureBox pictureBox1;
- private System.Windows.Forms.Button btnTest;
- private System.Windows.Forms.CheckBox checkBox1;
- private System.Windows.Forms.CheckBox checkBox2;
- private System.Windows.Forms.DateTimePicker dateTimePicker1;
- private System.Windows.Forms.Button button1;
- Font _fontReg;
- public mainFrm()
- {
- //
- // Required for Windows Form Designer support
- //
- InitializeComponent();
-
- //
- // TODO: Add any constructor code after InitializeComponent call
- //
- _fontBld = new Font("Arial", 8, FontStyle.Bold);
- _fontReg = new Font("Arial", 8, FontStyle.Regular);
- helpProvider1.SetHelpString(txtAge, "Enter an age that is less then 65");
- helpProvider1.SetHelpString(txtZipCode, "Enter a 5 digit zip code");
- }
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (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.components = new System.ComponentModel.Container();
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(mainFrm));
- this.mnuMain = new System.Windows.Forms.MainMenu();
- this.mnuFile = new System.Windows.Forms.MenuItem();
- this.mnuFileNew = new System.Windows.Forms.MenuItem();
- this.mnuFileOpen = new System.Windows.Forms.MenuItem();
- this.mnuFileClose = new System.Windows.Forms.MenuItem();
- this.menuItem1 = new System.Windows.Forms.MenuItem();
- this.mnuFileExit = new System.Windows.Forms.MenuItem();
- this.mnuEdit = new System.Windows.Forms.MenuItem();
- this.mnuEditCut = new System.Windows.Forms.MenuItem();
- this.mnuEditCopy = new System.Windows.Forms.MenuItem();
- this.mnuEditPaste = new System.Windows.Forms.MenuItem();
- this.menuItem2 = new System.Windows.Forms.MenuItem();
- this.mnuEditFind = new System.Windows.Forms.MenuItem();
- this.menuItem11 = new System.Windows.Forms.MenuItem();
- this.menuItem12 = new System.Windows.Forms.MenuItem();
- this.menuItem13 = new System.Windows.Forms.MenuItem();
- this.menuItem14 = new System.Windows.Forms.MenuItem();
- this.menuItem15 = new System.Windows.Forms.MenuItem();
- this.menuItem16 = new System.Windows.Forms.MenuItem();
- this.tbMain = new System.Windows.Forms.ToolBar();
- this.tbtnNew = new System.Windows.Forms.ToolBarButton();
- this.tbtnOpen = new System.Windows.Forms.ToolBarButton();
- this.sep0 = new System.Windows.Forms.ToolBarButton();
- this.tbtnEdit = new System.Windows.Forms.ToolBarButton();
- this.cmnuEdit = new System.Windows.Forms.ContextMenu();
- this.cmnuEditCut = new System.Windows.Forms.MenuItem();
- this.cmnuEditCopy = new System.Windows.Forms.MenuItem();
- this.cmnuEditPaste = new System.Windows.Forms.MenuItem();
- this.sep1 = new System.Windows.Forms.ToolBarButton();
- this.tbtnIconLocation = new System.Windows.Forms.ToolBarButton();
- this.tbtnStyle = new System.Windows.Forms.ToolBarButton();
- this.ilToolbar = new System.Windows.Forms.ImageList(this.components);
- this.errMain = new System.Windows.Forms.ErrorProvider();
- this.panel1 = new System.Windows.Forms.Panel();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.txtZipCode = new System.Windows.Forms.TextBox();
- this.txtAge = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.helpProvider1 = new System.Windows.Forms.HelpProvider();
- this.btnTest = new System.Windows.Forms.Button();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.statusBar1 = new System.Windows.Forms.StatusBar();
- this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
- this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
- this.tabControl1 = new System.Windows.Forms.TabControl();
- this.tabPage1 = new System.Windows.Forms.TabPage();
- this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
- this.label4 = new System.Windows.Forms.Label();
- this.tabPage2 = new System.Windows.Forms.TabPage();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.grpToolbarIcon = new System.Windows.Forms.GroupBox();
- this.rbTop = new System.Windows.Forms.RadioButton();
- this.rbRight = new System.Windows.Forms.RadioButton();
- this.checkBox1 = new System.Windows.Forms.CheckBox();
- this.checkBox2 = new System.Windows.Forms.CheckBox();
- this.button1 = new System.Windows.Forms.Button();
- this.panel1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
- this.tabControl1.SuspendLayout();
- this.tabPage1.SuspendLayout();
- this.tabPage2.SuspendLayout();
- this.grpToolbarIcon.SuspendLayout();
- this.SuspendLayout();
- //
- // mnuMain
- //
- this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.mnuFile,
- this.mnuEdit,
- this.menuItem11});
- //
- // mnuFile
- //
- this.mnuFile.Index = 0;
- this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.mnuFileNew,
- this.mnuFileOpen,
- this.mnuFileClose,
- this.menuItem1,
- this.mnuFileExit});
- this.mnuFile.Text = "&File";
- //
- // mnuFileNew
- //
- this.mnuFileNew.Index = 0;
- this.mnuFileNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
- this.mnuFileNew.Text = "&New";
- //
- // mnuFileOpen
- //
- this.mnuFileOpen.Index = 1;
- this.mnuFileOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
- this.mnuFileOpen.Text = "&Open";
- //
- // mnuFileClose
- //
- this.mnuFileClose.Index = 2;
- this.mnuFileClose.Text = "&Close";
- //
- // menuItem1
- //
- this.menuItem1.Index = 3;
- this.menuItem1.Text = "-";
- //
- // mnuFileExit
- //
- this.mnuFileExit.Index = 4;
- this.mnuFileExit.Text = "E&xit";
- this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click);
- //
- // mnuEdit
- //
- this.mnuEdit.Index = 1;
- this.mnuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.mnuEditCut,
- this.mnuEditCopy,
- this.mnuEditPaste,
- this.menuItem2,
- this.mnuEditFind});
- this.mnuEdit.Text = "&Edit";
- //
- // mnuEditCut
- //
- this.mnuEditCut.Index = 0;
- this.mnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
- this.mnuEditCut.Text = "Cu&t";
- //
- // mnuEditCopy
- //
- this.mnuEditCopy.Index = 1;
- this.mnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
- this.mnuEditCopy.Text = "&Copy";
- //
- // mnuEditPaste
- //
- this.mnuEditPaste.Index = 2;
- this.mnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
- this.mnuEditPaste.Text = "&Paste";
- //
- // menuItem2
- //
- this.menuItem2.Index = 3;
- this.menuItem2.Text = "-";
- //
- // mnuEditFind
- //
- this.mnuEditFind.Index = 4;
- this.mnuEditFind.Shortcut = System.Windows.Forms.Shortcut.CtrlF;
- this.mnuEditFind.Text = "&Find";
- //
- // menuItem11
- //
- this.menuItem11.Index = 2;
- this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem12,
- this.menuItem13,
- this.menuItem14});
- this.menuItem11.Text = "&App";
- //
- // menuItem12
- //
- this.menuItem12.Index = 0;
- this.menuItem12.Text = "Do Something";
- //
- // menuItem13
- //
- this.menuItem13.Checked = true;
- this.menuItem13.Index = 1;
- this.menuItem13.Shortcut = System.Windows.Forms.Shortcut.CtrlShiftC;
- this.menuItem13.Text = "Is Checked";
- //
- // menuItem14
- //
- this.menuItem14.Index = 2;
- this.menuItem14.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.menuItem15,
- this.menuItem16});
- this.menuItem14.Text = "Sub Menu";
- //
- // menuItem15
- //
- this.menuItem15.Index = 0;
- this.menuItem15.Text = "Sub Sub Menu";
- //
- // menuItem16
- //
- this.menuItem16.Index = 1;
- this.menuItem16.Text = "Another Sub Menu";
- //
- // tbMain
- //
- this.tbMain.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
- this.tbtnNew,
- this.tbtnOpen,
- this.sep0,
- this.tbtnEdit,
- this.sep1,
- this.tbtnIconLocation,
- this.tbtnStyle});
- this.tbMain.DropDownArrows = true;
- this.tbMain.ImageList = this.ilToolbar;
- this.tbMain.Location = new System.Drawing.Point(0, 0);
- this.tbMain.Name = "tbMain";
- this.tbMain.ShowToolTips = true;
- this.tbMain.Size = new System.Drawing.Size(488, 28);
- this.tbMain.TabIndex = 0;
- this.tbMain.TextAlign = System.Windows.Forms.ToolBarTextAlign.Right;
- this.tbMain.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.tbMain_ButtonClick);
- //
- // tbtnNew
- //
- this.tbtnNew.ImageIndex = 0;
- this.tbtnNew.Text = "New";
- this.tbtnNew.ToolTipText = "Create new document";
- //
- // tbtnOpen
- //
- this.tbtnOpen.ImageIndex = 1;
- this.tbtnOpen.Text = "Open";
- this.tbtnOpen.ToolTipText = "Open existing document";
- //
- // sep0
- //
- this.sep0.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
- //
- // tbtnEdit
- //
- this.tbtnEdit.DropDownMenu = this.cmnuEdit;
- this.tbtnEdit.Style = System.Windows.Forms.ToolBarButtonStyle.DropDownButton;
- this.tbtnEdit.Text = "Edit";
- this.tbtnEdit.ToolTipText = "Cop, Cut and Paste";
- //
- // cmnuEdit
- //
- this.cmnuEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
- this.cmnuEditCut,
- this.cmnuEditCopy,
- this.cmnuEditPaste});
- //
- // cmnuEditCut
- //
- this.cmnuEditCut.Index = 0;
- this.cmnuEditCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
- this.cmnuEditCut.Text = "Cut";
- //
- // cmnuEditCopy
- //
- this.cmnuEditCopy.Index = 1;
- this.cmnuEditCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
- this.cmnuEditCopy.Text = "Copy";
- //
- // cmnuEditPaste
- //
- this.cmnuEditPaste.Index = 2;
- this.cmnuEditPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
- this.cmnuEditPaste.Text = "Paste";
- //
- // sep1
- //
- this.sep1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
- //
- // tbtnIconLocation
- //
- this.tbtnIconLocation.ImageIndex = 2;
- this.tbtnIconLocation.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
- this.tbtnIconLocation.Text = "Icon";
- this.tbtnIconLocation.ToolTipText = "Icon is beside or beneath the text";
- //
- // tbtnStyle
- //
- this.tbtnStyle.ImageIndex = 4;
- this.tbtnStyle.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;
- this.tbtnStyle.Text = "Style";
- this.tbtnStyle.ToolTipText = "Changes the style of the toolbar.";
- //
- // ilToolbar
- //
- this.ilToolbar.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
- this.ilToolbar.ImageSize = new System.Drawing.Size(16, 16);
- this.ilToolbar.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ilToolbar.ImageStream")));
- this.ilToolbar.TransparentColor = System.Drawing.Color.Transparent;
- //
- // errMain
- //
- this.errMain.ContainerControl = this;
- //
- // panel1
- //
- this.panel1.Controls.Add(this.label2);
- this.panel1.Controls.Add(this.label1);
- this.panel1.Controls.Add(this.txtZipCode);
- this.panel1.Controls.Add(this.txtAge);
- this.panel1.Location = new System.Drawing.Point(224, 88);
- this.panel1.Name = "panel1";
- this.panel1.Size = new System.Drawing.Size(224, 88);
- this.panel1.TabIndex = 9;
- //
- // label2
- //
- this.label2.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label2.Location = new System.Drawing.Point(14, 45);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(64, 23);
- this.label2.TabIndex = 12;
- this.label2.Text = "Zip Code";
- this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.label2.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
- this.label2.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
- //
- // label1
- //
- this.label1.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.label1.Location = new System.Drawing.Point(14, 21);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(64, 23);
- this.label1.TabIndex = 11;
- this.label1.Text = "Age:";
- this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.label1.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
- this.label1.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
- //
- // txtZipCode
- //
- this.txtZipCode.Location = new System.Drawing.Point(86, 45);
- this.txtZipCode.Name = "txtZipCode";
- this.txtZipCode.TabIndex = 10;
- this.txtZipCode.Text = "";
- this.txtZipCode.Validating += new System.ComponentModel.CancelEventHandler(this.txtZipCode_Validating);
- //
- // txtAge
- //
- this.txtAge.Location = new System.Drawing.Point(86, 21);
- this.txtAge.Name = "txtAge";
- this.txtAge.TabIndex = 9;
- this.txtAge.Text = "";
- this.txtAge.Validating += new System.ComponentModel.CancelEventHandler(this.txtAge_Validating);
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(224, 64);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(128, 16);
- this.label3.TabIndex = 10;
- this.label3.Text = "Error Provider Example";
- //
- // btnTest
- //
- this.btnTest.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.btnTest.Location = new System.Drawing.Point(224, 208);
- this.btnTest.Name = "btnTest";
- this.btnTest.TabIndex = 11;
- this.btnTest.Text = "Sample";
- this.btnTest.Click += new System.EventHandler(this.btnTest_Click);
- //
- // comboBox1
- //
- this.comboBox1.Items.AddRange(new object[] {
- "Item 1",
- "Item 2",
- "Item 3",
- "Item 4"});
- this.comboBox1.Location = new System.Drawing.Point(224, 256);
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(121, 21);
- this.comboBox1.TabIndex = 12;
- this.comboBox1.Text = "comboBox1";
- this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
- //
- // statusBar1
- //
- this.statusBar1.Location = new System.Drawing.Point(0, 537);
- this.statusBar1.Name = "statusBar1";
- this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
- this.statusBarPanel1,
- this.statusBarPanel2});
- this.statusBar1.ShowPanels = true;
- this.statusBar1.Size = new System.Drawing.Size(488, 24);
- this.statusBar1.TabIndex = 13;
- this.statusBar1.Text = "statusBar1";
- //
- // statusBarPanel1
- //
- this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
- this.statusBarPanel1.Text = "This is the first panel";
- this.statusBarPanel1.Width = 118;
- //
- // statusBarPanel2
- //
- this.statusBarPanel2.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
- this.statusBarPanel2.Text = "This is the second panel";
- this.statusBarPanel2.Width = 354;
- //
- // tabControl1
- //
- this.tabControl1.Controls.Add(this.tabPage1);
- this.tabControl1.Controls.Add(this.tabPage2);
- this.tabControl1.Location = new System.Drawing.Point(24, 304);
- this.tabControl1.Name = "tabControl1";
- this.tabControl1.SelectedIndex = 0;
- this.tabControl1.Size = new System.Drawing.Size(424, 224);
- this.tabControl1.TabIndex = 14;
- //
- // tabPage1
- //
- this.tabPage1.Controls.Add(this.dateTimePicker1);
- this.tabPage1.Controls.Add(this.label4);
- this.tabPage1.Location = new System.Drawing.Point(4, 22);
- this.tabPage1.Name = "tabPage1";
- this.tabPage1.Size = new System.Drawing.Size(416, 198);
- this.tabPage1.TabIndex = 0;
- this.tabPage1.Text = "Tab Page 1";
- //
- // dateTimePicker1
- //
- this.dateTimePicker1.Location = new System.Drawing.Point(24, 48);
- this.dateTimePicker1.Name = "dateTimePicker1";
- this.dateTimePicker1.TabIndex = 1;
- this.dateTimePicker1.ValueChanged += new System.EventHandler(this.dateTimePicker1_ValueChanged);
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(24, 16);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(152, 23);
- this.label4.TabIndex = 0;
- this.label4.Text = "This is a label on a tab page";
- //
- // tabPage2
- //
- this.tabPage2.Controls.Add(this.pictureBox1);
- this.tabPage2.Location = new System.Drawing.Point(4, 22);
- this.tabPage2.Name = "tabPage2";
- this.tabPage2.Size = new System.Drawing.Size(416, 198);
- this.tabPage2.TabIndex = 1;
- this.tabPage2.Text = "Another Tab Page";
- //
- // pictureBox1
- //
- this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
- this.pictureBox1.Location = new System.Drawing.Point(40, 16);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(352, 168);
- this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
- this.pictureBox1.TabIndex = 0;
- this.pictureBox1.TabStop = false;
- //
- // grpToolbarIcon
- //
- this.grpToolbarIcon.Controls.Add(this.rbTop);
- this.grpToolbarIcon.Controls.Add(this.rbRight);
- this.grpToolbarIcon.FlatStyle = System.Windows.Forms.FlatStyle.System;
- this.grpToolbarIcon.Location = new System.Drawing.Point(32, 80);
- this.grpToolbarIcon.Name = "grpToolbarIcon";
- this.grpToolbarIcon.Size = new System.Drawing.Size(144, 88);
- this.grpToolbarIcon.TabIndex = 15;
- this.grpToolbarIcon.TabStop = false;
- this.grpToolbarIcon.Text = "Location";
- //
- // rbTop
- //
- this.rbTop.Location = new System.Drawing.Point(16, 56);
- this.rbTop.Name = "rbTop";
- this.rbTop.TabIndex = 1;
- this.rbTop.Text = "Top";
- this.rbTop.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
- this.rbTop.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
- this.rbTop.CheckedChanged += new System.EventHandler(this.rbTop_CheckedChanged);
- //
- // rbRight
- //
- this.rbRight.Checked = true;
- this.rbRight.Location = new System.Drawing.Point(16, 24);
- this.rbRight.Name = "rbRight";
- this.rbRight.TabIndex = 0;
- this.rbRight.TabStop = true;
- this.rbRight.Text = "Right";
- this.rbRight.MouseEnter += new System.EventHandler(this.ControlMouseEnter);
- this.rbRight.MouseLeave += new System.EventHandler(this.ControlMouseLeave);
- this.rbRight.CheckedChanged += new System.EventHandler(this.rbRight_CheckedChanged);
- //
- // checkBox1
- //
- this.checkBox1.Location = new System.Drawing.Point(32, 200);
- this.checkBox1.Name = "checkBox1";
- this.checkBox1.TabIndex = 16;
- this.checkBox1.Text = "checkBox1";
- this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
- //
- // checkBox2
- //
- this.checkBox2.Location = new System.Drawing.Point(32, 224);
- this.checkBox2.Name = "checkBox2";
- this.checkBox2.TabIndex = 17;
- this.checkBox2.Text = "checkBox2";
- this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(312, 208);
- this.button1.Name = "button1";
- this.button1.TabIndex = 18;
- this.button1.Text = "Default";
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // mainFrm
- //
- this.AcceptButton = this.button1;
- this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
- this.ClientSize = new System.Drawing.Size(488, 561);
- this.Controls.Add(this.button1);
- this.Controls.Add(this.checkBox2);
- this.Controls.Add(this.checkBox1);
- this.Controls.Add(this.grpToolbarIcon);
- this.Controls.Add(this.tabControl1);
- this.Controls.Add(this.statusBar1);
- this.Controls.Add(this.comboBox1);
- this.Controls.Add(this.btnTest);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.panel1);
- this.Controls.Add(this.tbMain);
- this.Menu = this.mnuMain;
- this.Name = "mainFrm";
- this.Text = "Menu and Toolbars";
- this.panel1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
- this.tabControl1.ResumeLayout(false);
- this.tabPage1.ResumeLayout(false);
- this.tabPage2.ResumeLayout(false);
- this.grpToolbarIcon.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main()
- {
- //Uncomment the following two lines to see what EnableVisualStyles looks like
- //Requires Windows XP or Windows 2003.
- // Application.EnableVisualStyles();
- // Application.DoEvents();
- Application.Run(new mainFrm());
- }
- //event handler for the exit menu.
- private void mnuFileExit_Click(object sender, System.EventArgs e)
- {
- Application.Exit();
- }
- /// <summary>
- /// This is the button clicked event handler for the toolbar buttons.
- /// All of the buttons on the toolbar use the same event. the button that was
- /// clicked is passed in the ToolBarButtonClickEventArgs paramter. Therefore in the handler
- /// you must differentiate which button raised the event in a switch statement.
- /// This example uses the text property of the button.
- /// </summary>
- /// <param name="sender">Object raising event</param>
- /// <param name="e"></param>
- private void tbMain_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
- {
-
- switch(e.Button.Text)
- {
-
- case "New" :
- {
- MessageBox.Show("The New toolbar button was selected.");
- break;
- }
- case "Open" :
- {
- MessageBox.Show(e.Button.Text + " toolbar button was selected.");
- break;
- }
- case "Icon" :
- {
- if(e.Button.Pushed)
- e.Button.ImageIndex = 3;
- else
- e.Button.ImageIndex = 2;
- if(tbMain.TextAlign == ToolBarTextAlign.Right)
- tbMain.TextAlign = ToolBarTextAlign.Underneath;
- else
- tbMain.TextAlign = ToolBarTextAlign.Right;
- break;
- }
- case "Style" :
- {
- if(e.Button.Pushed)
- tbMain.Appearance = ToolBarAppearance.Flat;
- else
- tbMain.Appearance = ToolBarAppearance.Normal;
- break;
- }
- }
-
- }
- //Handles the MouseEnter event on a control that supports the Font property.
- private void ControlMouseEnter(object sender, EventArgs e)
- {
- ((Control)sender).Font = _fontBld;
- }
-
- //Handles the MouseLeave event on controls that supports the Font property
- private void ControlMouseLeave(object sender, EventArgs e)
- {
- ((Control)sender).Font = _fontReg;
- }
- /// <summary>
- /// The Validing event for the txtAge text box. This is the ErrorProvider example.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtAge_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if(txtAge.TextLength > 0 && Convert.ToInt32(txtAge.Text) > 65)
- {
- errMain.SetIconAlignment((Control)sender, ErrorIconAlignment.MiddleRight);
- errMain.SetError((Control)sender, "Value must be less then 65.");
- e.Cancel = true;
- }
- else
- {
- errMain.SetError((Control)sender, "");
- }
- }
- /// <summary>
- /// Validating event for txtZipCode to support the ErrorProvider example
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void txtZipCode_Validating(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if(txtZipCode.Text.Length != 5)
- {
- errMain.SetIconAlignment((Control)sender, ErrorIconAlignment.MiddleRight);
- errMain.SetError((Control)sender, "Must be 5 charactors..");
- e.Cancel = true;
- }
- else
- {
- errMain.SetError((Control)sender, "");
- }
- }
- /// <summary>
- /// CheckedChanged event handler for the rbRight radio button
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
-
- private void rbRight_CheckedChanged(object sender, System.EventArgs e)
- {
- MessageBox.Show(((RadioButton)sender).Name + " has changed.");
- }
- /// <summary>
- /// ChaeckedChanged event handler for the rbTop Radio Button
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rbTop_CheckedChanged(object sender, System.EventArgs e)
- {
- MessageBox.Show(((RadioButton)sender).Name + " has changed.");
- }
-
- /// <summary>
- /// Button1 Click event handler.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnTest_Click(object sender, System.EventArgs e)
- {
- MessageBox.Show(((Button)sender).Name + " was clicked.");
- }
- private void checkBox_CheckedChanged(object sender, System.EventArgs e)
- {
- MessageBox.Show(((CheckBox)sender).Name + " changed");
- }
- private void dateTimePicker1_ValueChanged(object sender, System.EventArgs e)
- {
- label4.Text = dateTimePicker1.Text;
- }
- private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
- {
- MessageBox.Show(((ComboBox)sender).Items[((ComboBox)sender).SelectedIndex].ToString() + " selected");
- }
- private void button1_Click(object sender, System.EventArgs e)
- {
- MessageBox.Show(((Button)sender).Name + " was clicked. This is the Default button.");
- }
- }
- }