当前位置: 首页>>代码示例>>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;未经允许,请勿转载。