当前位置: 首页>>代码示例>>C#>>正文


C# Forms.Button类代码示例

本文整理汇总了C#中System.Windows.Forms.Button的典型用法代码示例。如果您正苦于以下问题:C# Button类的具体用法?C# Button怎么用?C# Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Button类属于System.Windows.Forms命名空间,在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeComponent

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.listBox1 = new System.Windows.Forms.ListBox();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(32, 32);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(208, 23);
			this.button1.TabIndex = 0;
			this.button1.Text = "Call \"HelloWorld\" on remote object";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// listBox1
			// 
			this.listBox1.Location = new System.Drawing.Point(32, 72);
			this.listBox1.Name = "listBox1";
			this.listBox1.Size = new System.Drawing.Size(224, 95);
			this.listBox1.TabIndex = 1;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(292, 266);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.listBox1,
																		  this.button1});
			this.Name = "Form1";
			this.Text = "RemoteObject";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}
开发者ID:emtees,项目名称:old-code,代码行数:39,代码来源:Form1.cs

示例2: AddEventosABM

 public static void AddEventosABM(Control grpCampos, ref Button btnGrabar, ref DataTable tbl)
 {
     tblTabla = tbl;
     tblTabla.ColumnChanged += new DataColumnChangeEventHandler(HabilitarGrabar);
     grabar = btnGrabar;
     foreach (Control ctl in grpCampos.Controls)
     {
         if (ctl is TextBox)
         {
             ctl.Enter += new System.EventHandler(SelTextoTextBox);
             ctl.KeyDown += new System.Windows.Forms.KeyEventHandler(EnterTab);
         }
         if (ctl is MaskedTextBox)
         {
             ctl.KeyDown += new System.Windows.Forms.KeyEventHandler(EnterTab);
         }
     }
     foreach (Control ctl in grpCampos.Controls)
     {
         if (ctl is ComboBox)
         {
             ctl.KeyDown += new System.Windows.Forms.KeyEventHandler(EnterTab);
         }
     }
 }
开发者ID:BenjaOtero,项目名称:trend-pos-factura,代码行数:25,代码来源:Utilitarios.cs

示例3: Initialize

        public override void Initialize()
        {
            //txtLocation = new System.Windows.Forms.TextBox();
            //txtLocation.Size = new System.Drawing.Size(238, 24);
            //txtLocation.Top = 100;
            //txtLocation.Left = 12;

            //lblLocation = new System.Windows.Forms.Label();
            //lblLocation.Size = new System.Drawing.Size(238, 24);
            //lblLocation.Top = txtLocation.Top - 16;
            //lblLocation.Left = txtLocation.Left;
            //lblLocation.Text = "Location (eg: sim/x/y/z)";

            cmdObjects = new System.Windows.Forms.Button();
            cmdObjects.Size = new System.Drawing.Size(120, 24);
            cmdObjects.Top = 100; cmdObjects.Left = 257;
            cmdObjects.Text = "List Objects";

            //cmdObjects.Click += new System.EventHandler(this.cmdObjects_OnClick);
            cmdObjects.Click += (new frmObjects(instance)).Show();

            //TabPage.Controls.Add(txtLocation);
            //TabPage.Controls.Add(lblLocation);
            TabPage.Controls.Add(cmdObjects);
        }
开发者ID:NullProjects,项目名称:METAbolt,代码行数:25,代码来源:HeightmapInterface.cs

示例4: ToolbarPresenter

        public ToolbarPresenter(Button utenteButton, Sessione sessione)
        {
            _utenteButton = utenteButton;
            _utenteButton.Click += UtenteButton_click;

            _sessione = sessione;
        }
开发者ID:VforVentordici,项目名称:GameReViews,代码行数:7,代码来源:ToolbarPresenter.cs

示例5: TestShowWithEvents

        public void TestShowWithEvents()
        {
            //---------------Set up test pack-------------------
            System.Windows.Forms.DateTimePicker dateTimePicker = new System.Windows.Forms.DateTimePicker();
            dateTimePicker.ShowCheckBox = true;
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            System.Windows.Forms.TextBox textBox = new System.Windows.Forms.TextBox();
            form.Controls.Add(textBox);
            textBox.Dock = System.Windows.Forms.DockStyle.Fill;
            textBox.Multiline = true;
            form.Controls.Add(dateTimePicker);
            dateTimePicker.Dock = System.Windows.Forms.DockStyle.Top;
            dateTimePicker.ValueChanged += delegate
                                               {
                                                   textBox.Text += "EventFired";
                                               };
            System.Windows.Forms.Button button = new System.Windows.Forms.Button();
            form.Controls.Add(button);
            button.Dock = System.Windows.Forms.DockStyle.Bottom;
            button.Click += delegate
                                {
                                    dateTimePicker.Checked = !dateTimePicker.Checked;
                                };
            //-------------Assert Preconditions -------------

            //---------------Execute Test ----------------------
            form.ShowDialog();
            //---------------Test Result -----------------------

        }
开发者ID:Chillisoft,项目名称:habanero.faces,代码行数:30,代码来源:TestDateTimePickerWin.cs

示例6: InsertPInvokeSignaturesForm

		public InsertPInvokeSignaturesForm()
		{
			SetupFromXmlStream(this.GetType().Assembly.GetManifestResourceStream("PInvokeAddIn.Resources.InsertPInvokeSignaturesForm.xfrm"));
			
			signatureRichTextBox = ((RichTextBox)ControlDictionary["SignatureRichTextBox"]);
			
			// Hook up events.
			closeButton = ((Button)ControlDictionary["CloseButton"]);
			closeButton.Click += new EventHandler(CloseButtonClick);
			
			insertButton = ((Button)ControlDictionary["InsertButton"]);
			insertButton.Enabled = false;
			insertButton.Click += new EventHandler(InsertButtonClick);
			
			findButton = ((Button)ControlDictionary["FindButton"]);
			findButton.Click += new EventHandler(FindButtonClick);
			
			functionNameComboBox = ((ComboBox)ControlDictionary["FunctionNameComboBox"]);
			functionNameComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
			functionNameComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;

			moduleNameComboBox = ((ComboBox)ControlDictionary["ModuleNameComboBox"]);
			moduleNameComboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
			moduleNameComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
			
			moreInfoLinkLabel = ((LinkLabel)ControlDictionary["MoreInfoLinkLabel"]);
			moreInfoLinkLabel.LinkClicked += new LinkLabelLinkClickedEventHandler(MoreInfoLinkClicked);

			languageComboBox = ((ComboBox)ControlDictionary["LanguageComboBox"]);
			languageComboBox.SelectedIndexChanged += new EventHandler(LanguageComboBoxSelectedIndexChanged);
			
			SetupLanguages();
			SetupFunctionNames();
			SetupModuleNames();
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:35,代码来源:InsertPInvokeSignaturesForm.cs

示例7: InitializeComponent

        private void InitializeComponent()
        {
            this.Text = "Excel Form";
            this.StartPosition = FormStartPosition.CenterScreen;
            this.FormBorderStyle = FormBorderStyle.FixedDialog;
            this.ControlBox = true;
            this.MaximizeBox = false;
            this.MinimizeBox = false;
            this.BackColor = Color.Red;

            btnOK = new Button();
            btnOK.Text = "OK";
            btnOK.Left = this.ClientRectangle.Width-btnOK.Width-10;
            btnOK.Top = this.ClientRectangle.Height-btnOK.Height-10;
            btnOK.Visible = true;
            btnOK.Click += new EventHandler(btnOK_Click);
            this.Controls.Add(btnOK);

            btnCreate = new Button();
            btnCreate.Text = "Create";
            btnCreate.Left = this.ClientRectangle.Width - btnOK.Width - 150;
            btnCreate.Top = this.ClientRectangle.Height - btnOK.Height - 10;
            btnCreate.Visible = true;
            btnCreate.Click += new EventHandler(btnCreate_Click);
            this.Controls.Add(btnCreate);
        }
开发者ID:dbremner,项目名称:hycs,代码行数:26,代码来源:excel_create.cs

示例8: BigBlockEdit_Load

        private void BigBlockEdit_Load(object sender, EventArgs e)
        {
            curTileset = 0;
            curVideo = 0x90;
            curPallete = 0;
            curPart = 0;
            dirty = false;
            updateSaveVisibility();
            curViewType = MapViewType.Tiles;

            initControls();
        
            blocksPanel.Controls.Clear();
            blocksPanel.SuspendLayout();
            for (int i = 0; i < SMALL_BLOCKS_COUNT; i++)
            {
                var but = new Button();
                but.FlatStyle = FlatStyle.Flat;
                but.Size = new Size(32, 32);
                but.ImageList = smallBlocks;
                but.ImageIndex = i;
                but.Margin = new Padding(0);
                but.Padding = new Padding(0);
                but.Click += new EventHandler(buttonObjClick);
                blocksPanel.Controls.Add(but);
            }
            blocksPanel.ResumeLayout();
 
            reloadLevel();

            readOnly = false; //must be read from config
            tbbSave.Enabled = !readOnly;
            tbbImport.Enabled = !readOnly;
        }
开发者ID:ghostdogtm,项目名称:CadEditor,代码行数:34,代码来源:BigBlockEdit.cs

示例9: RemoveAll

        public static void RemoveAll(Control control)
        {
            if ((control != null) && (control.Controls.Count > 0))
            {
                Button tempButton = null;
                Form parentForm = control.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

              				// Remove all entries from target
                control.Controls.Clear();

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
开发者ID:krishnais,项目名称:ProfileSharp,代码行数:31,代码来源:ControlHelper.cs

示例10: Remove

        public static void Remove(Control.ControlCollection coll, Control item)
        {
            if ((coll != null) && (item != null))
            {
                Button tempButton = null;
                Form parentForm = item.FindForm();

                if (parentForm != null)
                {
                    // Create a hidden, temporary button
                    tempButton = new Button();
                    tempButton.Visible = false;

                    // Add this temporary button to the parent form
                    parentForm.Controls.Add(tempButton);

                    // Must ensure that temp button is the active one
                    parentForm.ActiveControl = tempButton;
                }

                // Remove our target control
                coll.Remove(item);

                if (parentForm != null)
                {
                    // Remove the temporary button
                    tempButton.Dispose();
                    parentForm.Controls.Remove(tempButton);
                }
            }
        }
开发者ID:krishnais,项目名称:ProfileSharp,代码行数:31,代码来源:ControlHelper.cs

示例11: AddRow

        public void AddRow(String path, int rateNum)
        {
            var removeButton = new Button();
            removeButton.Image = IconResource.remove_small;
            removeButton.Size = addButton.Size;
            removeButton.Tag = _pathButtons.Count;
            removeButton.Click += OnRemove;
            _removeButtons.Add(removeButton);

            var pathButton = new Button();
            pathButton.Text = path;
            pathButton.Size = addPathButton.Size;
            pathButton.Click += addPathButton_Click;
            _pathButtons.Add(pathButton);

            var rateComboBox = new ComboBox();
            rateComboBox.Items.AddRange(_rates);
            rateComboBox.SelectedIndex = Math.Min(rateNum, _rates.Length);
            rateComboBox.Size = addRateComboBox.Size;
            _rateComboBoxes.Add(rateComboBox);

            int rowCount = _pathButtons.Count;
            rowContainer.RowCount = rowCount;
            rowContainer.Height = 28 * rowCount;
            rowContainer.Controls.Add(removeButton, 0, rowCount - 1);
            rowContainer.Controls.Add(pathButton, 1, rowCount - 1);
            rowContainer.Controls.Add(rateComboBox, 2, rowCount - 1);
        }
开发者ID:qedsyrt,项目名称:yotarif-win,代码行数:28,代码来源:RateProcessControl.cs

示例12: InitializeComponent

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.btnRun = new System.Windows.Forms.Button();
			this.btnAbout = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.checkBox1 = new System.Windows.Forms.CheckBox();
			this.SuspendLayout();
			// 
			// btnRun
			// 
			this.btnRun.Location = new System.Drawing.Point(448, 56);
			this.btnRun.Name = "btnRun";
			this.btnRun.Size = new System.Drawing.Size(72, 23);
			this.btnRun.TabIndex = 2;
			this.btnRun.Text = "Run";
			this.btnRun.Click += new System.EventHandler(this.btnRun_Click);
			// 
			// btnAbout
			// 
			this.btnAbout.Location = new System.Drawing.Point(528, 56);
			this.btnAbout.Name = "btnAbout";
			this.btnAbout.TabIndex = 3;
			this.btnAbout.Text = "Close";
			this.btnAbout.Click += new System.EventHandler(this.btnAbout_Click);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.Location = new System.Drawing.Point(16, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(558, 18);
			this.label1.TabIndex = 4;
			this.label1.Text = "The sample demonstrates how to create percent stacked line chart in an excel work" +
				"book.";
			// 
			// checkBox1
			// 
			this.checkBox1.Location = new System.Drawing.Point(24, 48);
			this.checkBox1.Name = "checkBox1";
			this.checkBox1.Size = new System.Drawing.Size(160, 24);
			this.checkBox1.TabIndex = 5;
			this.checkBox1.Text = "Stacked markers chart";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(616, 94);
			this.Controls.Add(this.checkBox1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.btnAbout);
			this.Controls.Add(this.btnRun);
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Form1";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Chart sample";
			this.ResumeLayout(false);

		}
开发者ID:spirecomponent,项目名称:.NETExcelLibrary,代码行数:64,代码来源:Form1.cs

示例13: InitializeComponent

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.label1 = new System.Windows.Forms.Label();
			this.txtLine = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(24, 18);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(72, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "Line Number";
			// 
			// txtLine
			// 
			this.txtLine.Location = new System.Drawing.Point(104, 16);
			this.txtLine.Name = "txtLine";
			this.txtLine.Size = new System.Drawing.Size(112, 20);
			this.txtLine.TabIndex = 1;
			this.txtLine.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(240, 16);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 2;
			this.btnOK.Text = "&OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(240, 48);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 3;
			this.btnCancel.Text = "&Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// Goto
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(338, 87);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.txtLine);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "Goto";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "Go To";
			this.ResumeLayout(false);

		}
开发者ID:nguyenhuuhuy,项目名称:mygeneration,代码行数:64,代码来源:Goto.cs

示例14: ConstructorTest

		public void ConstructorTest()
		{
			INuGenServiceProvider serviceProvider = new NuGenControlServiceProvider();
			try
			{
				_sketchCanvas = new NuGenSketchCanvas((IntPtr)(-1), serviceProvider);
				Assert.Fail();
			}
			catch (ArgumentException)
			{
			}

			Button button = new Button();
			button.CreateControl();
			Assert.IsTrue(button.IsHandleCreated);

			try
			{
				_sketchCanvas = new NuGenSketchCanvas(button.Handle, serviceProvider);
			}
			catch
			{
				Assert.Fail();
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:25,代码来源:NuGenSketchCanvasTests.cs

示例15: InitializeComponent

 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.button1 = new System.Windows.Forms.Button();
     this.textBox1 = new System.Windows.Forms.TextBox();
     this.SuspendLayout();
     //
     // button1
     //
     this.button1.Location = new System.Drawing.Point(56, 64);
     this.button1.Name = "button1";
     this.button1.Size = new System.Drawing.Size(168, 80);
     this.button1.TabIndex = 0;
     this.button1.Text = "button1";
     this.button1.Click += new System.EventHandler(this.button1_Click);
     //
     // textBox1
     //
     this.textBox1.Location = new System.Drawing.Point(64, 184);
     this.textBox1.Name = "textBox1";
     this.textBox1.Size = new System.Drawing.Size(176, 20);
     this.textBox1.TabIndex = 1;
     this.textBox1.Text = "textBox1";
     //
     // Form1
     //
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize = new System.Drawing.Size(292, 273);
     this.Controls.AddRange(new System.Windows.Forms.Control[] {
                                                                   this.textBox1,
                                                                   this.button1});
     this.Name = "Form1";
     this.Text = "Form1";
     this.ResumeLayout(false);
 }
开发者ID:aleksey-zhidkov,项目名称:School-stuff,代码行数:38,代码来源:Form1.cs


注:本文中的System.Windows.Forms.Button类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。