ToolStripButton クラスとは? わかりやすく解説

ToolStripButton クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

テキストイメージ格納できる選択可能な ToolStripItem を表します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class ToolStripButton
    Inherits ToolStripItem
Dim instance As ToolStripButton
public class ToolStripButton : ToolStripItem
public ref class ToolStripButton : public
 ToolStripItem
public class ToolStripButton extends ToolStripItem
public class ToolStripButton extends
 ToolStripItem
解説解説

ToolStripButton使用すると、テキストイメージ両方サポートするツール バー ボタン作成できますToolStripButtonイメージテキスト位置取得または設定するには、ToolStripItem.ImageAlign プロパティと ToolStripItem.TextAlign プロパティ使用します

ToolStripButton では、以前のバージョンの ToolBarButton コントロール機能置換または拡張されていますが、下位互換性維持し今後使用できるように、ToolBarButton残されています。

使用例使用例

イメージテキスト両方を含む 2 つToolStripButton コントロールを ToolStrip 上に表示するコード例次に示しますToolStripButton の [New] をクリックすると、メッセージ ボックス表示されます。

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.
        }
    }
}
継承階層継承階層
System.Object
   System.MarshalByRefObject
     System.ComponentModel.Component
       System.Windows.Forms.ToolStripItem
        System.Windows.Forms.ToolStripButton
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ToolStripButton クラス」の関連用語

ToolStripButton クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ToolStripButton クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS