當前位置: 首頁>>代碼示例>>C#>>正文


C# ToolStripButton類代碼示例

本文整理匯總了C#中System.Windows.Forms.ToolStripButton的典型用法代碼示例。如果您正苦於以下問題:C# ToolStripButton類的具體用法?C# ToolStripButton怎麽用?C# ToolStripButton使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ToolStripButton類屬於System.Windows.Forms命名空間,在下文中一共展示了ToolStripButton類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Form1

//引入命名空間
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsApplication11
{
    public class Form1 : Form
    {
        private ToolStripButton toolStripButton1;
        private ToolStripButton toolStripButton2;
        private ToolStrip toolStrip1;
    
        public Form1()
        {
            InitializeComponent();
        }
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        private void InitializeComponent()
        {
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton1 = new System.Windows.Forms.ToolStripButton();
            this.toolStripButton2 = new System.Windows.Forms.ToolStripButton();
            this.toolStrip1.SuspendLayout();
            this.SuspendLayout();
            // 
            // toolStrip1
            // 
            this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton1,
            this.toolStripButton2});
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.Text = "toolStrip1";
            // 
            // toolStripButton1
            //
            this.toolStripButton1.Image = Bitmap.FromFile("c:\\NewItem.bmp");
            this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
            this.toolStripButton1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.toolStripButton1.Name = "toolStripButton1";
            this.toolStripButton1.Text = "&New";
            this.toolStripButton1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
            // 
            // toolStripButton2
            // 
            this.toolStripButton2.Image = Bitmap.FromFile("c:\\OpenItem.bmp");
            this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.ImageAndText;
            this.toolStripButton2.Name = "toolStripButton2";
            this.toolStripButton2.Text = "&Open";
            this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
            // 
            // Form1
            // 
            this.ClientSize = new System.Drawing.Size(292, 273);
            this.Controls.Add(this.toolStrip1);
            this.Name = "Form1";
            this.toolStrip1.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You have mail.");
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            // Add the response to the Click event here.
        }
    }
}
開發者ID:.NET開發者,項目名稱:System.Windows.Forms,代碼行數:84,代碼來源:ToolStripButton


注:本文中的System.Windows.Forms.ToolStripButton類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。