ToolStripItem 클래스

정의

ToolStrip 또는 ToolStripDropDown에 포함될 수 있는 모든 요소의 이벤트와 레이아웃을 관리하는 추상 기본 클래스를 나타냅니다.

public ref class ToolStripItem abstract : System::ComponentModel::Component, IDisposable, System::Windows::Forms::IDropTarget
public ref class ToolStripItem abstract : System::Windows::Forms::BindableComponent, IDisposable, System::Windows::Forms::IDropTarget
public abstract class ToolStripItem : System.ComponentModel.Component, IDisposable, System.Windows.Forms.IDropTarget
public abstract class ToolStripItem : System.Windows.Forms.BindableComponent, IDisposable, System.Windows.Forms.IDropTarget
type ToolStripItem = class
    inherit Component
    interface IDropTarget
    interface IComponent
    interface IDisposable
type ToolStripItem = class
    inherit BindableComponent
    interface IDropTarget
    interface IComponent
    interface IDisposable
Public MustInherit Class ToolStripItem
Inherits Component
Implements IDisposable, IDropTarget
Public MustInherit Class ToolStripItem
Inherits BindableComponent
Implements IDisposable, IDropTarget
상속
상속
파생
구현

예제

다음 코드 예제에서는 사용자 지정 ToolStripItem 컨트롤을 구현 하는 방법을 보여 줍니다.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;

namespace RolloverItemDemoLib
{
    // This class implements a ToolStripItem that highlights
    // its border and text when the mouse enters its
    // client rectangle. It has a clickable state which is
    // exposed through the Clicked property and displayed
    // by highlighting or graying out the item's image. 
    public class RolloverItem : ToolStripItem
    {
        private bool clickedValue = false;
        private bool rolloverValue = false;

        private Rectangle imageRect;
        private Rectangle textRect;

        // For brevity, this implementation limits the possible 
        // TextDirection values to ToolStripTextDirection.Horizontal. 
        public override ToolStripTextDirection TextDirection
        {
            get
            {
                return base.TextDirection;
            }
            set
            {
                if (value == ToolStripTextDirection.Horizontal)
                {
                    base.TextDirection = value;
                }
                else
                {
                    throw new ArgumentException(
                        "RolloverItem supports only horizontal text.");
                }
            }
        }

        // For brevity, this implementation limits the possible 
        // TextImageRelation values to ImageBeforeText and TextBeforeImage. 
        public new TextImageRelation TextImageRelation
        {
            get
            {
                return base.TextImageRelation;
            }

            set
            {
                if (value == TextImageRelation.ImageBeforeText || 
                    value == TextImageRelation.TextBeforeImage)
                {
                    base.TextImageRelation = value;
                }
                else
                {
                    throw new ArgumentException(
                        "Unsupported TextImageRelation value.");
                }
            }
        }
        
        // This property returns true if the mouse is 
        // inside the client rectangle.
        public bool Rollover
        {
            get
            {
                return this.rolloverValue;
            }   
        }

        // This property returns true if the item 
        // has been toggled into the clicked state.
        // Clicking again toggles it to the 
        // unclicked state.
        public bool Clicked
        {
            get
            {
                return this.clickedValue;
            }
        }

        // The method defines the behavior of the Click event.
        // It simply toggles the state of the clickedValue field.
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            this.clickedValue ^= true;
        }

        // The method defines the behavior of the DoubleClick 
        // event. It shows a MessageBox with the item's text.
        protected override void OnDoubleClick(EventArgs e)
        {
            base.OnDoubleClick(e);

            string msg = String.Format("Item: {0}", this.Text);

            MessageBox.Show(msg);
        }

        // This method defines the behavior of the MouseEnter event.
        // It sets the state of the rolloverValue field to true and
        // tells the control to repaint.
        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);

            this.rolloverValue = true;

            this.Invalidate();
        }

        // This method defines the behavior of the MouseLeave event.
        // It sets the state of the rolloverValue field to false and
        // tells the control to repaint.
        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            this.rolloverValue = false;

            this.Invalidate();
        }

        // This method defines the painting behavior of the control.
        // It performs the following operations:
        //
        // Computes the layout of the item's image and text.
        // Draws the item's background image.
        // Draws the item's image.
        // Draws the item's text.
        //
        // Drawing operations are implemented in the 
        // RolloverItemRenderer class.
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            if (this.Owner != null)
            {
                // Find the dimensions of the image and the text 
                // areas of the item. 
                this.ComputeImageAndTextLayout();

                // Draw the background. This includes drawing a highlighted 
                // border when the mouse is in the client area.
                ToolStripItemRenderEventArgs ea = new ToolStripItemRenderEventArgs(
                     e.Graphics,
                     this);
                this.Owner.Renderer.DrawItemBackground(ea);

                // Draw the item's image. 
                ToolStripItemImageRenderEventArgs irea =
                    new ToolStripItemImageRenderEventArgs(
                    e.Graphics,
                    this,
                    imageRect );
                this.Owner.Renderer.DrawItemImage(irea);

                // If the item is on a drop-down, give its
                // text a different highlighted color.
                Color highlightColor = 
                    this.IsOnDropDown ?
                    Color.Salmon : SystemColors.ControlLightLight;

                // Draw the text, and highlight it if the 
                // the rollover state is true.
                ToolStripItemTextRenderEventArgs rea =
                    new ToolStripItemTextRenderEventArgs(
                    e.Graphics,
                    this,
                    base.Text,
                    textRect,
                    this.rolloverValue ? highlightColor : base.ForeColor,
                    base.Font,
                    base.TextAlign);
                this.Owner.Renderer.DrawItemText(rea);
            }
        }

        // This utility method computes the layout of the 
        // RolloverItem control's image area and the text area.
        // For brevity, only the following settings are 
        // supported:
        //
        // ToolStripTextDirection.Horizontal
        // TextImageRelation.ImageBeforeText 
        // TextImageRelation.ImageBeforeText
        // 
        // It would not be difficult to support vertical text
        // directions and other image/text relationships.
        private void ComputeImageAndTextLayout()
        {
            Rectangle cr = base.ContentRectangle;
            Image img = base.Owner.ImageList.Images[base.ImageKey];

            // Compute the center of the item's ContentRectangle.
            int centerY = (cr.Height - img.Height) / 2;

            // Find the dimensions of the image and the text 
            // areas of the item. The text occupies the space 
            // not filled by the image. 
            if (base.TextImageRelation == TextImageRelation.ImageBeforeText &&
                base.TextDirection == ToolStripTextDirection.Horizontal)
            {
                imageRect = new Rectangle(
                    base.ContentRectangle.Left,
                    centerY,
                    base.Image.Width,
                    base.Image.Height);

                textRect = new Rectangle(
                    imageRect.Width,
                    base.ContentRectangle.Top,
                    base.ContentRectangle.Width - imageRect.Width,
                    base.ContentRectangle.Height);
            }
            else if (base.TextImageRelation == TextImageRelation.TextBeforeImage &&
                     base.TextDirection == ToolStripTextDirection.Horizontal)
            {
                imageRect = new Rectangle(
                    base.ContentRectangle.Right - base.Image.Width,
                    centerY,
                    base.Image.Width,
                    base.Image.Height);

                textRect = new Rectangle(
                    base.ContentRectangle.Left,
                    base.ContentRectangle.Top,
                    imageRect.X,
                    base.ContentRectangle.Bottom);
            }
        }
    }

    #region RolloverItemRenderer

    // This is the custom renderer for the RolloverItem control.
    // It draws a border around the item when the mouse is
    // in the item's client area. It also draws the item's image
    // in an inactive state (grayed out) until the user clicks
    // the item to toggle its "clicked" state.
    internal class RolloverItemRenderer : ToolStripSystemRenderer
    {
        protected override void OnRenderItemImage(
            ToolStripItemImageRenderEventArgs e)
        {
            base.OnRenderItemImage(e);

            RolloverItem item = e.Item as RolloverItem;

            // If the ToolSTripItem is of type RolloverItem, 
            // perform custom rendering for the image.
            if (item != null)
            {
                if (item.Clicked)
                {
                    // The item is in the clicked state, so 
                    // draw the image as usual.
                    e.Graphics.DrawImage(
                        e.Image,
                        e.ImageRectangle.X,
                        e.ImageRectangle.Y);
                }
                else
                {
                    // In the unclicked state, gray out the image.
                    ControlPaint.DrawImageDisabled(
                        e.Graphics,
                        e.Image,
                        e.ImageRectangle.X,
                        e.ImageRectangle.Y,
                        item.BackColor);
                }
            }
        }

        // This method defines the behavior for rendering the
        // background of a ToolStripItem. If the item is a
        // RolloverItem, it paints the item's BackgroundImage 
        // centered in the client area. If the mouse is in the 
        // item's client area, a border is drawn around it.
        // If the item is on a drop-down or if it is on the
        // overflow, a gradient is painted in the background.
        protected override void OnRenderItemBackground(
            ToolStripItemRenderEventArgs e)
        {
            base.OnRenderItemBackground(e);

            RolloverItem item = e.Item as RolloverItem;

            // If the ToolSTripItem is of type RolloverItem, 
            // perform custom rendering for the background.
            if (item != null)
            {
                if (item.Placement == ToolStripItemPlacement.Overflow ||
                    item.IsOnDropDown)
                {
                    using (LinearGradientBrush b = new LinearGradientBrush(
                        item.ContentRectangle,
                        Color.Salmon,
                        Color.DarkRed,
                        0f,
                        false))
                    {
                        e.Graphics.FillRectangle(b, item.ContentRectangle);
                    }
                }

                // The RolloverItem control only supports 
                // the ImageLayout.Center setting for the
                // BackgroundImage property.
                if (item.BackgroundImageLayout == ImageLayout.Center)
                {
                    // Get references to the item's ContentRectangle
                    // and BackgroundImage, for convenience.
                    Rectangle cr = item.ContentRectangle;
                    Image bgi = item.BackgroundImage;

                    // Compute the center of the item's ContentRectangle.
                    int centerX = (cr.Width - bgi.Width) / 2;
                    int centerY = (cr.Height - bgi.Height) / 2;

                    // If the item is selected, draw the background
                    // image as usual. Otherwise, draw it as disabled.
                    if (item.Selected)
                    {
                        e.Graphics.DrawImage(bgi, centerX, centerY);
                    }
                    else
                    {
                        ControlPaint.DrawImageDisabled(
                                e.Graphics,
                                bgi,
                                centerX,
                                centerY,
                                item.BackColor);
                    }
                }

                // If the item is in the rollover state, 
                // draw a border around it.
                if (item.Rollover)
                {
                    ControlPaint.DrawFocusRectangle(
                        e.Graphics,
                        item.ContentRectangle);
                }
            }
        }

    #endregion

    }

    // This form tests various features of the RolloverItem
    // control. RolloverItem conrols are created and added
    // to the form's ToolStrip. They are also created and 
    // added to a button's ContextMenuStrip. The behavior
    // of the RolloverItem control differs depending on 
    // the type of parent control.
    public class RolloverItemTestForm : Form
    {
        private System.Windows.Forms.ToolStrip toolStrip1;
        private System.Windows.Forms.Button button1;

        private string infoIconKey = "Information icon";
        private string handIconKey = "Hand icon";
        private string exclIconKey = "Exclamation icon";
        private string questionIconKey = "Question icon";
        private string warningIconKey = "Warning icon ";

        private System.ComponentModel.IContainer components = null;

        public RolloverItemTestForm()
        {
            InitializeComponent();

            // Set up the form's ToolStrip control.
            InitializeToolStrip();

            // Set up the ContextMenuStrip for the button.
            InitializeContextMenu();
        }

        // This utility method initializes the ToolStrip control's 
        // image list. For convenience, icons from the SystemIcons 
        // class are used for this demonstration, but any images
        // could be used.
        private void InitializeImageList(ToolStrip ts)
        {
            if (ts.ImageList == null)
            {
                ts.ImageList = new ImageList();
                ts.ImageList.ImageSize = SystemIcons.Exclamation.Size;

                ts.ImageList.Images.Add(
                    this.infoIconKey,
                    SystemIcons.Information);

                ts.ImageList.Images.Add(
                    this.handIconKey,
                    SystemIcons.Hand);

                ts.ImageList.Images.Add(
                    this.exclIconKey,
                    SystemIcons.Exclamation);

                ts.ImageList.Images.Add(
                    this.questionIconKey,
                    SystemIcons.Question);

                ts.ImageList.Images.Add(
                    this.warningIconKey,
                    SystemIcons.Warning);
            }
        }

        private void InitializeToolStrip()
        {
            this.InitializeImageList(this.toolStrip1);

            this.toolStrip1.Renderer = new RolloverItemRenderer();

            RolloverItem item = this.CreateRolloverItem(
                this.toolStrip1,
                "RolloverItem on ToolStrip",
                this.Font,
                infoIconKey,
                TextImageRelation.ImageBeforeText,
                exclIconKey);

            this.toolStrip1.Items.Add(item);

            item = this.CreateRolloverItem(
                this.toolStrip1,
                "RolloverItem on ToolStrip",
                this.Font,
                infoIconKey,
                TextImageRelation.ImageBeforeText,
                exclIconKey);

            this.toolStrip1.Items.Add(item);
        }

        private void InitializeContextMenu()
        {
            Font f = new System.Drawing.Font(
                "Arial",
                18f,
                FontStyle.Bold);

            ContextMenuStrip cms = new ContextMenuStrip();
            this.InitializeImageList(cms);

            cms.Renderer = new RolloverItemRenderer();
            cms.AutoSize = true;
            cms.ShowCheckMargin = false;
            cms.ShowImageMargin = false;

            RolloverItem item = this.CreateRolloverItem(
                cms,
                "RolloverItem on ContextMenuStrip",
                f,
                handIconKey,
                TextImageRelation.ImageBeforeText,
                exclIconKey);

            cms.Items.Add(item);

            item = this.CreateRolloverItem(
                cms,
                "Another RolloverItem on ContextMenuStrip",
                f,
                questionIconKey,
                TextImageRelation.ImageBeforeText,
                exclIconKey);

            cms.Items.Add(item);

            item = this.CreateRolloverItem(
                cms,
                "And another RolloverItem on ContextMenuStrip",
                f,
                warningIconKey,
                TextImageRelation.ImageBeforeText,
                exclIconKey);

            cms.Items.Add(item);

            cms.Closing += new ToolStripDropDownClosingEventHandler(cms_Closing);

            this.button1.ContextMenuStrip = cms;
        }

        // This method handles the ContextMenuStrip 
        // control's Closing event. It prevents the 
        // RolloverItem from closing the drop-down  
        // when the item is clicked.
        void cms_Closing(object sender, ToolStripDropDownClosingEventArgs e)
        {
            if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)
            {
                e.Cancel = true;
            }
        }

        // This method handles the Click event for the button.
        // it selects the first item in the ToolStrip control
        // by using the ToolStripITem.Select method.
        private void button1_Click(object sender, EventArgs e)
        {
            RolloverItem item = this.toolStrip1.Items[0] as RolloverItem;

            if (item != null)
            {
                item.Select();

                this.Invalidate();
            }
        }

        // This utility method creates a RolloverItem 
        // and adds it to a ToolStrip control.
        private RolloverItem CreateRolloverItem(
            ToolStrip owningToolStrip,
            string txt,
            Font f,
            string imgKey,
            TextImageRelation tir,
            string backImgKey)
        {
            RolloverItem item = new RolloverItem();

            item.Alignment = ToolStripItemAlignment.Left;
            item.AllowDrop = false;
            item.AutoSize = true;

            item.BackgroundImage = owningToolStrip.ImageList.Images[backImgKey];
            item.BackgroundImageLayout = ImageLayout.Center;
            item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText;
            item.DoubleClickEnabled = true;
            item.Enabled = true;
            item.Font = f;

            // These assignments are equivalent. Each assigns an
            // image from the owning toolstrip's image list.
            item.ImageKey = imgKey;
            //item.Image = owningToolStrip.ImageList.Images[infoIconKey];
            //item.ImageIndex = owningToolStrip.ImageList.Images.IndexOfKey(infoIconKey);
            item.ImageScaling = ToolStripItemImageScaling.None;

            item.Owner = owningToolStrip;
            item.Padding = new Padding(2);
            item.Text = txt;
            item.TextAlign = ContentAlignment.MiddleLeft;
            item.TextDirection = ToolStripTextDirection.Horizontal;
            item.TextImageRelation = tir;

            return item;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        private void InitializeComponent()
        {
            this.toolStrip1 = new System.Windows.Forms.ToolStrip();
            this.button1 = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // toolStrip1
            // 
            this.toolStrip1.AllowItemReorder = true;
            this.toolStrip1.Location = new System.Drawing.Point(0, 0);
            this.toolStrip1.Name = "toolStrip1";
            this.toolStrip1.Size = new System.Drawing.Size(845, 25);
            this.toolStrip1.TabIndex = 0;
            this.toolStrip1.Text = "toolStrip1";
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(12, 100);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(86, 23);
            this.button1.TabIndex = 1;
            this.button1.Text = "Click to select";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // RolloverItemTestForm
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 14F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.AutoSize = true;
            this.ClientSize = new System.Drawing.Size(845, 282);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.toolStrip1);
            this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Name = "RolloverItemTestForm";
            this.Text = "Form1";
            this.ResumeLayout(false);
            this.PerformLayout();
        }

        #endregion
    }

    static class Program
    {   
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new RolloverItemTestForm());
        }
    }
}
Option Strict On
Option Explicit On

Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms

' This class implements a ToolStripItem that highlights
' its border and text when the mouse enters its
' client rectangle. It has a clickable state which is
' exposed through the Clicked property and displayed
' by highlighting or graying out the item's image. 
Public Class RolloverItem
    Inherits ToolStripItem

   Private clickedValue As Boolean = False
   Private rolloverValue As Boolean = False
   
   Private imageRect As Rectangle
   Private textRect As Rectangle
   
   ' For brevity, this implementation limits the possible 
   ' TextDirection values to ToolStripTextDirection.Horizontal. 
   Public Overrides Property TextDirection() As ToolStripTextDirection
      Get
         Return MyBase.TextDirection
      End Get
      Set
         If value = ToolStripTextDirection.Horizontal Then
            MyBase.TextDirection = value
         Else
                Throw New ArgumentException( _
                "RolloverItem supports only horizontal text.")
         End If
      End Set
   End Property
   
   ' For brevity, this implementation limits the possible 
   ' TextImageRelation values to ImageBeforeText and TextBeforeImage. 
   Public Shadows Property TextImageRelation() As TextImageRelation
      Get
         Return MyBase.TextImageRelation
      End Get
      
      Set
            If Value = TextImageRelation.ImageBeforeText OrElse _
               Value = TextImageRelation.TextBeforeImage Then
                MyBase.TextImageRelation = Value
            Else
                Throw New ArgumentException("Unsupported TextImageRelation value.")
            End If
      End Set
   End Property
   
   ' This property returns true if the mouse is 
   ' inside the client rectangle.
   Public ReadOnly Property Rollover() As Boolean
      Get
         Return Me.rolloverValue
      End Get
    End Property

   ' This property returns true if the item 
   ' has been toggled into the clicked state.
   ' Clicking again toggles it to the 
   ' unclicked state.
   Public ReadOnly Property Clicked() As Boolean
      Get
         Return Me.clickedValue
      End Get
   End Property
   
   ' The method defines the behavior of the Click event.
   ' It simply toggles the state of the clickedValue field.
   Protected Overrides Sub OnClick(e As EventArgs)
      MyBase.OnClick(e)
      
        Me.clickedValue = Me.clickedValue Xor True
    End Sub

   ' The method defines the behavior of the DoubleClick 
   ' event. It shows a MessageBox with the item's text.
   Protected Overrides Sub OnDoubleClick(e As EventArgs)
      MyBase.OnDoubleClick(e)
      
      Dim msg As String = String.Format("Item: {0}", Me.Text)
      
      MessageBox.Show(msg)
    End Sub

   ' This method defines the behavior of the MouseEnter event.
   ' It sets the state of the rolloverValue field to true and
   ' tells the control to repaint.
   Protected Overrides Sub OnMouseEnter(e As EventArgs)
      MyBase.OnMouseEnter(e)
      
      Me.rolloverValue = True
      
      Me.Invalidate()
    End Sub
   
   ' This method defines the behavior of the MouseLeave event.
   ' It sets the state of the rolloverValue field to false and
   ' tells the control to repaint.
   Protected Overrides Sub OnMouseLeave(e As EventArgs)
      MyBase.OnMouseLeave(e)
      
      Me.rolloverValue = False
      
      Me.Invalidate()
    End Sub
   
   ' This method defines the painting behavior of the control.
   ' It performs the following operations:
   '
   ' Computes the layout of the item's image and text.
   ' Draws the item's background image.
   ' Draws the item's image.
   ' Draws the item's text.
   '
   ' Drawing operations are implemented in the 
   ' RolloverItemRenderer class.
   Protected Overrides Sub OnPaint(e As PaintEventArgs)
      MyBase.OnPaint(e)
      
      If (Me.Owner IsNot Nothing) Then
         ' Find the dimensions of the image and the text 
         ' areas of the item. 
         Me.ComputeImageAndTextLayout()
         
         ' Draw the background. This includes drawing a highlighted 
         ' border when the mouse is in the client area.
         Dim ea As New ToolStripItemRenderEventArgs(e.Graphics, Me)
         Me.Owner.Renderer.DrawItemBackground(ea)
         
         ' Draw the item's image. 
         Dim irea As New ToolStripItemImageRenderEventArgs(e.Graphics, Me, imageRect)
         Me.Owner.Renderer.DrawItemImage(irea)
         
         ' If the item is on a drop-down, give its
         ' text a different highlighted color.
            Dim highlightColor As Color = CType(IIf(Me.IsOnDropDown, Color.Salmon, SystemColors.ControlLightLight), Color)
         
         ' Draw the text, and highlight it if the 
         ' the rollover state is true.
            Dim rea As New ToolStripItemTextRenderEventArgs( _
               e.Graphics, _
               Me, _
               MyBase.Text, _
               textRect, _
               CType(IIf(Me.rolloverValue, highlightColor, MyBase.ForeColor), Color), _
               MyBase.Font, _
               MyBase.TextAlign)
         Me.Owner.Renderer.DrawItemText(rea)
      End If
    End Sub

   ' This utility method computes the layout of the 
   ' RolloverItem control's image area and the text area.
   ' For brevity, only the following settings are 
   ' supported:
   '
   ' ToolStripTextDirection.Horizontal
   ' TextImageRelation.ImageBeforeText 
   ' TextImageRelation.ImageBeforeText
   ' 
   ' It would not be difficult to support vertical text
   ' directions and other image/text relationships.
   Private Sub ComputeImageAndTextLayout()
      Dim cr As Rectangle = MyBase.ContentRectangle
      Dim img As Image = MyBase.Owner.ImageList.Images(MyBase.ImageKey)
      
      ' Compute the center of the item's ContentRectangle.
        Dim centerY As Integer = CInt((cr.Height - img.Height) / 2)
      
      ' Find the dimensions of the image and the text 
      ' areas of the item. The text occupies the space 
      ' not filled by the image. 
        If MyBase.TextImageRelation = _
        TextImageRelation.ImageBeforeText AndAlso _
        MyBase.TextDirection = ToolStripTextDirection.Horizontal Then

            imageRect = New Rectangle( _
            MyBase.ContentRectangle.Left, _
            centerY, _
            MyBase.Image.Width, _
            MyBase.Image.Height)

            textRect = New Rectangle( _
            imageRect.Width, _
            MyBase.ContentRectangle.Top, _
            MyBase.ContentRectangle.Width - imageRect.Width, _
            MyBase.ContentRectangle.Height)

        ElseIf MyBase.TextImageRelation = _
        TextImageRelation.TextBeforeImage AndAlso _
        MyBase.TextDirection = ToolStripTextDirection.Horizontal Then

            imageRect = New Rectangle( _
            MyBase.ContentRectangle.Right - MyBase.Image.Width, _
            centerY, _
            MyBase.Image.Width, _
            MyBase.Image.Height)

            textRect = New Rectangle( _
            MyBase.ContentRectangle.Left, _
            MyBase.ContentRectangle.Top, _
            imageRect.X, _
            MyBase.ContentRectangle.Bottom)

        End If
    End Sub
End Class

' This is the custom renderer for the RolloverItem control.
' It draws a border around the item when the mouse is
' in the item's client area. It also draws the item's image
' in an inactive state (grayed out) until the user clicks
' the item to toggle its "clicked" state.
Friend Class RolloverItemRenderer
    Inherits ToolStripSystemRenderer

    Protected Overrides Sub OnRenderItemImage(ByVal e As ToolStripItemImageRenderEventArgs)
        MyBase.OnRenderItemImage(e)

        Dim item As RolloverItem = CType(e.Item, RolloverItem)

        ' If the ToolSTripItem is of type RolloverItem, 
        ' perform custom rendering for the image.
        If (item IsNot Nothing) Then
            If item.Clicked Then
                ' The item is in the clicked state, so 
                ' draw the image as usual.
                e.Graphics.DrawImage(e.Image, e.ImageRectangle.X, e.ImageRectangle.Y)
            Else
                ' In the unclicked state, gray out the image.
                ControlPaint.DrawImageDisabled(e.Graphics, e.Image, e.ImageRectangle.X, e.ImageRectangle.Y, item.BackColor)
            End If
        End If
    End Sub

    ' This method defines the behavior for rendering the
    ' background of a ToolStripItem. If the item is a
    ' RolloverItem, it paints the item's BackgroundImage 
    ' centered in the client area. If the mouse is in the 
    ' item's client area, a border is drawn around it.
    ' If the item is on a drop-down or if it is on the
    ' overflow, a gradient is painted in the background.
    Protected Overrides Sub OnRenderItemBackground(ByVal e As ToolStripItemRenderEventArgs)
        MyBase.OnRenderItemBackground(e)

        Dim item As RolloverItem = CType(e.Item, RolloverItem)

        ' If the ToolSTripItem is of type RolloverItem, 
        ' perform custom rendering for the background.
        If (item IsNot Nothing) Then
            If item.Placement = ToolStripItemPlacement.Overflow OrElse item.IsOnDropDown Then
                Dim b As New LinearGradientBrush(item.ContentRectangle, Color.Salmon, Color.DarkRed, 0.0F, False)
                Try
                    e.Graphics.FillRectangle(b, item.ContentRectangle)
                Finally
                    b.Dispose()
                End Try
            End If

            ' The RolloverItem control only supports 
            ' the ImageLayout.Center setting for the
            ' BackgroundImage property.
            If item.BackgroundImageLayout = ImageLayout.Center Then
                ' Get references to the item's ContentRectangle
                ' and BackgroundImage, for convenience.
                Dim cr As Rectangle = item.ContentRectangle
                Dim bgi As Image = item.BackgroundImage

                ' Compute the center of the item's ContentRectangle.
                Dim centerX As Integer = CInt((cr.Width - bgi.Width) / 2)
                Dim centerY As Integer = CInt((cr.Height - bgi.Height) / 2)

                ' If the item is selected, draw the background
                ' image as usual. Otherwise, draw it as disabled.
                If item.Selected Then
                    e.Graphics.DrawImage(bgi, centerX, centerY)
                Else
                    ControlPaint.DrawImageDisabled(e.Graphics, bgi, centerX, centerY, item.BackColor)
                End If
            End If

            ' If the item is in the rollover state, 
            ' draw a border around it.
            If item.Rollover Then
                ControlPaint.DrawFocusRectangle(e.Graphics, item.ContentRectangle)
            End If
        End If
    End Sub

End Class

' This form tests various features of the RolloverItem
' control. RolloverItem conrols are created and added
' to the form's ToolStrip. They are also created and 
' added to a button's ContextMenuStrip. The behavior
' of the RolloverItem control differs depending on 
' the type of parent control.

Public Class RolloverItemTestForm
   Inherits Form
   Private toolStrip1 As System.Windows.Forms.ToolStrip
   Private WithEvents button1 As System.Windows.Forms.Button
   
   Private infoIconKey As String = "Information icon"
   Private handIconKey As String = "Hand icon"
   Private exclIconKey As String = "Exclamation icon"
   Private questionIconKey As String = "Question icon"
   Private warningIconKey As String = "Warning icon "
   
   Private components As System.ComponentModel.IContainer = Nothing
   
   
   Public Sub New()
      InitializeComponent()
      
      ' Set up the form's ToolStrip control.
      InitializeToolStrip()
      
      ' Set up the ContextMenuStrip for the button.
      InitializeContextMenu()
    End Sub
   
   
   ' This utility method initializes the ToolStrip control's 
   ' image list. For convenience, icons from the SystemIcons 
   ' class are used for this demonstration, but any images
   ' could be used.
   Private Sub InitializeImageList(ts As ToolStrip)
      If ts.ImageList Is Nothing Then
         ts.ImageList = New ImageList()
         ts.ImageList.ImageSize = SystemIcons.Exclamation.Size
         
         ts.ImageList.Images.Add(Me.infoIconKey, SystemIcons.Information)
         
         ts.ImageList.Images.Add(Me.handIconKey, SystemIcons.Hand)
         
         ts.ImageList.Images.Add(Me.exclIconKey, SystemIcons.Exclamation)
         
         ts.ImageList.Images.Add(Me.questionIconKey, SystemIcons.Question)
         
         ts.ImageList.Images.Add(Me.warningIconKey, SystemIcons.Warning)
      End If
    End Sub
   
   
   Private Sub InitializeToolStrip()
      Me.InitializeImageList(Me.toolStrip1)
      
      Me.toolStrip1.Renderer = New RolloverItemRenderer()
      
      Dim item As RolloverItem = Me.CreateRolloverItem(Me.toolStrip1, "RolloverItem on ToolStrip", Me.Font, infoIconKey, TextImageRelation.ImageBeforeText, exclIconKey)
      
      Me.toolStrip1.Items.Add(item)
      
      item = Me.CreateRolloverItem(Me.toolStrip1, "RolloverItem on ToolStrip", Me.Font, infoIconKey, TextImageRelation.ImageBeforeText, exclIconKey)
      
      Me.toolStrip1.Items.Add(item)
    End Sub
   
   
   Private Sub InitializeContextMenu()
        Dim f As New System.Drawing.Font("Arial", 18.0F, FontStyle.Bold)
      
      Dim cms As New ContextMenuStrip()
      Me.InitializeImageList(cms)
      
      cms.Renderer = New RolloverItemRenderer()
      cms.AutoSize = True
      cms.ShowCheckMargin = False
      cms.ShowImageMargin = False
      
        Dim item As RolloverItem = Me.CreateRolloverItem( _
        cms, _
        "RolloverItem on ContextMenuStrip", _
        f, _
        handIconKey, _
        TextImageRelation.ImageBeforeText, _
        exclIconKey)
      
      cms.Items.Add(item)
      
        item = Me.CreateRolloverItem( _
        cms, _
        "Another RolloverItem on ContextMenuStrip", _
        f, _
        questionIconKey, _
        TextImageRelation.ImageBeforeText, _
        exclIconKey)
      
      cms.Items.Add(item)
      
        item = Me.CreateRolloverItem( _
        cms, _
        "And another RolloverItem on ContextMenuStrip", _
        CType(f, Drawing.Font), _
        warningIconKey, _
        TextImageRelation.ImageBeforeText, _
        exclIconKey)
      
      cms.Items.Add(item)
      
      AddHandler cms.Closing, AddressOf cms_Closing
      
      Me.button1.ContextMenuStrip = cms
    End Sub
   
   
   ' This method handles the ContextMenuStrip 
   ' control's Closing event. It prevents the 
   ' RolloverItem from closing the drop-down  
   ' when the item is clicked.
   Private Sub cms_Closing(sender As Object, e As ToolStripDropDownClosingEventArgs)
      If e.CloseReason = ToolStripDropDownCloseReason.ItemClicked Then
         e.Cancel = True
      End If
    End Sub
   
   
   ' This method handles the Click event for the button.
   ' it selects the first item in the ToolStrip control
   ' by using the ToolStripITem.Select method.
   Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click
        Dim item As RolloverItem = CType(Me.toolStrip1.Items(0), RolloverItem)
      
      If (item IsNot Nothing) Then
         item.Select()
         
         Me.Invalidate()
      End If
    End Sub

   ' This utility method creates a RolloverItem 
   ' and adds it to a ToolStrip control.
    Private Function CreateRolloverItem( _
    ByVal owningToolStrip As ToolStrip, _
    ByVal txt As String, _
    ByVal f As Font, _
    ByVal imgKey As String, _
    ByVal tir As TextImageRelation, _
    ByVal backImgKey As String) As RolloverItem

        Dim item As New RolloverItem()

        item.Alignment = ToolStripItemAlignment.Left
        item.AllowDrop = False
        item.AutoSize = True

        item.BackgroundImage = owningToolStrip.ImageList.Images(backImgKey)
        item.BackgroundImageLayout = ImageLayout.Center
        item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText
        item.DoubleClickEnabled = True
        item.Enabled = True
        item.Font = f

        ' These assignments are equivalent. Each assigns an
        ' image from the owning toolstrip's image list.
        item.ImageKey = imgKey
        'item.Image = owningToolStrip.ImageList.Images[infoIconKey];
        'item.ImageIndex = owningToolStrip.ImageList.Images.IndexOfKey(infoIconKey);
        item.ImageScaling = ToolStripItemImageScaling.None

        item.Owner = owningToolStrip
        item.Padding = New Padding(2)
        item.Text = txt
        item.TextAlign = ContentAlignment.MiddleLeft
        item.TextDirection = ToolStripTextDirection.Horizontal
        item.TextImageRelation = tir

        Return item
    End Function

   Protected Overrides Sub Dispose(disposing As Boolean)
      If disposing AndAlso (components IsNot Nothing) Then
         components.Dispose()
      End If
      MyBase.Dispose(disposing)
    End Sub
   
   #Region "Windows Form Designer generated code"
   
   Private Sub InitializeComponent()
      Me.toolStrip1 = New System.Windows.Forms.ToolStrip()
      Me.button1 = New System.Windows.Forms.Button()
      Me.SuspendLayout()
      ' 
      ' toolStrip1
      ' 
      Me.toolStrip1.AllowItemReorder = True
      Me.toolStrip1.Location = New System.Drawing.Point(0, 0)
      Me.toolStrip1.Name = "toolStrip1"
      Me.toolStrip1.Size = New System.Drawing.Size(845, 25)
      Me.toolStrip1.TabIndex = 0
      Me.toolStrip1.Text = "toolStrip1"
      ' 
      ' button1
      ' 
      Me.button1.Location = New System.Drawing.Point(12, 100)
      Me.button1.Name = "button1"
      Me.button1.Size = New System.Drawing.Size(86, 23)
      Me.button1.TabIndex = 1
      Me.button1.Text = "Click to select"
      Me.button1.UseVisualStyleBackColor = True
      ' 
      ' RolloverItemTestForm
      ' 
      Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 14F)
      Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
      Me.AutoSize = True
      Me.ClientSize = New System.Drawing.Size(845, 282)
      Me.Controls.Add(button1)
      Me.Controls.Add(toolStrip1)
        Me.Font = New System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
      Me.Name = "RolloverItemTestForm"
      Me.Text = "Form1"
      Me.ResumeLayout(False)
      Me.PerformLayout()
    End Sub
   
#End Region

End Class


Public Class Program

    <STAThread()> _
    Shared Sub Main()
        Application.EnableVisualStyles()
        Application.SetCompatibleTextRenderingDefault(False)
        Application.Run(New RolloverItemTestForm())
    End Sub
End Class

설명

ToolStripItem 은 Windows 바로 가기 메뉴와 유사한 컨트롤 또는 컨트롤에 포함될 수 있는 ToolStrip 단추, 콤보 상자, 텍스트 상자 또는 ToolStripDropDown 레이블과 같은 요소입니다. 클래스는 ToolStrip 이러한 요소에 대한 끌어서 놓기 입력을 포함하여 그리기 및 키보드 및 마우스 입력을 관리하고, 클래스는 ToolStripItem 요소 자체 내에서 이벤트 및 레이아웃을 관리합니다.

ToolStripItem 클래스는 ToolStripItem에서 직접 상속되거나 ToolStripControlHost 또는 ToolStripDropDownItem을 통해 ToolStripItem에서 간접적으로 상속됩니다.

ToolStripItem 컨트롤은 ToolStrip, MenuStrip, StatusStrip 또는 ContextMenuStrip에 포함되어야 하며 양식에 직접 추가될 수 없습니다. 다양한 컨테이너 클래스는 ToolStripItem 컨트롤의 적절한 하위 집합을 포함하도록 설계되었습니다.

참고 지정된 ToolStripItem 에 부모 가 둘 ToolStrip이상 있을 수 없습니다. 의 ToolStripItem 를 복사하여 다른 ToolStrip 컨트롤에 추가해야 합니다.

다음 표에서는 클래스에서 파생되어 또는 ToolStripDropDown에서 ToolStripItemToolStrip 호스트될 수 있는 요소를 보여줍니다.

요소 Description
ToolStripButton 이미지 및 텍스트를 지원하는 도구 모음 단추입니다.
ToolStripLabel 일반적으로 상태 표시줄 또는 주석 또는 ToolStrip 제목으로 사용되는 텍스트 레이블입니다.
ToolStripSeparator 요소를 시각적으로 그룹화할 수 있는 세로 막대가 있는 선택 불가능한 공간 또는 공간입니다.
ToolStripControlHost ToolStripItem, , ToolStripTextBox, ToolStripProgressBar기타 Windows Forms 컨트롤 또는 사용자 지정 컨트롤을 호스트ToolStripComboBox하는 입니다.

ToolStripComboBox 은 텍스트 상자를 채울 텍스트를 선택할 수 있는 목록과 함께 사용자가 텍스트를 입력할 수 있는 텍스트 상자입니다.

ToolStripTextBox 사용하면 사용자가 텍스트를 입력할 수 있습니다.

ToolStripProgressBar 에 포함된 Windows 진행률 표시줄 컨트롤을 StatusStrip나타냅니다.
ToolStripDropDownItem ToolStripItem, ToolStripSplitButtonToolStripDropDownButton를 호스트하는 입니다ToolStripMenuItem.

ToolStripMenuItem 은 메뉴 또는 상황에 맞는 메뉴에 표시되는 선택 가능한 옵션입니다.

ToolStripSplitButton 일반 단추와 드롭다운 단추의 조합입니다.

ToolStripDropDownButton 드롭다운 기능을 지원하는 단추입니다.
ToolStripStatusLabel 컨트롤의 패널입니다 StatusStrip .

생성자

ToolStripItem()

ToolStripItem 클래스의 새 인스턴스를 초기화합니다.

ToolStripItem(String, Image, EventHandler)

지정된 이름, 이미지 및 이벤트 처리기를 사용하여 ToolStripItem 클래스의 새 인스턴스를 초기화합니다.

ToolStripItem(String, Image, EventHandler, String)

지정된 표시 텍스트, 이미지, 이벤트 처리기 및 이름을 사용하여 ToolStripItem 클래스의 새 인스턴스를 초기화합니다.

속성

AccessibilityObject

컨트롤에 할당된 AccessibleObject를 가져옵니다.

AccessibleDefaultActionDescription

내게 필요한 옵션 지원 클라이언트 애플리케이션에서 사용되는 컨트롤의 기본 작업 설명을 가져오거나 설정합니다.

AccessibleDescription

내게 필요한 옵션 지원 클라이언트 애플리케이션에 보고할 설명을 가져오거나 설정합니다.

AccessibleName

내게 필요한 옵션 지원 클라이언트 애플리케이션에서 사용할 컨트롤의 이름을 가져오거나 설정합니다.

AccessibleRole

컨트롤의 사용자 인터페이스 요소 형식을 지정하는 내게 필요한 옵션 지원 역할을 가져오거나 설정합니다.

Alignment

항목이 ToolStrip의 시작 부분 방향으로 맞춰지는지 아니면 끝 부분 방향으로 맞춰지는지 나타내는 값을 가져오거나 설정합니다.

AllowDrop

사용자가 구현한 이벤트를 통해 끌어서 놓기 및 항목 다시 정렬을 처리할지 여부를 나타내는 값 가져오거나 설정합니다.

Anchor

ToolStripItem이 바인딩되는 컨테이너의 가장자리를 가져오거나 설정하고 해당 부모를 기초로 ToolStripItem 크기를 조정하는 방법을 결정합니다.

AutoSize

항목의 크기가 자동으로 조정되는지 여부를 나타내는 값을 가져오거나 설정합니다.

AutoToolTip

ToolTipText 도구 설명에 Text 속성 또는 ToolStripItem 속성을 사용할지 나타내는 값을 가져오거나 설정합니다.

Available

ToolStripItemToolStrip을 배치해야 하는지 여부를 나타내는 값을 가져오거나 설정합니다.

BackColor

항목의 배경색을 가져오거나 설정합니다.

BackgroundImage

항목에 표시할 배경 이미지를 가져오거나 설정합니다.

BackgroundImageLayout

ToolStripItem에 사용되는 배경 이미지 레이아웃을 가져오거나 설정합니다.

BindingContext

IBindableComponent에 대한 현재 위치 관리자의 컬렉션을 가져오거나 설정합니다.

(다음에서 상속됨 BindableComponent)
Bounds

항목의 크기와 위치를 가져옵니다.

CanRaiseEvents

구성 요소가 이벤트를 발생시킬 수 있는지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
CanSelect

항목을 선택할 수 있는지 여부를 나타내는 값을 가져옵니다.

Command

ToolStripItem의 Click 이벤트가 호출될 때 메서드가 호출될 을 가져오거나 설정합니다.ICommandExecute(Object)

CommandParameter

속성에 할당된 에 ICommand 전달되는 매개 변수를 Command 가져오거나 설정합니다.

Container

IContainer을 포함하는 Component를 가져옵니다.

(다음에서 상속됨 Component)
ContentRectangle

배경 테두리를 덮어쓰기 않고 ToolStripItem 안에 텍스트와 아이콘 같은 내용을 배치할 수 있는 영역을 가져옵니다.

DataBindings

IBindableComponent에 대한 데이터 바인딩 개체의 컬렉션을 가져옵니다.

(다음에서 상속됨 BindableComponent)
DefaultAutoToolTip

기본값으로 정의된 ToolTip을 표시할지 여부를 나타내는 값을 가져옵니다.

DefaultDisplayStyle

ToolStripItem에 표시되는 대상을 나타내는 값을 가져옵니다.

DefaultMargin

항목의 기본 여백을 가져옵니다.

DefaultPadding

항목의 내부 간격 특징을 가져옵니다.

DefaultSize

항목의 기본 크기를 가져옵니다.

DesignMode

Component가 현재 디자인 모드인지 여부를 나타내는 값을 가져옵니다.

(다음에서 상속됨 Component)
DismissWhenClicked

ToolStripDropDown에 있는 항목을 클릭할 경우 해당 항목을 숨길지 여부를 나타내는 값을 가져옵니다.

DisplayStyle

ToolStripItem에 텍스트 및 이미지를 표시할지 여부를 나타내는 값을 가져오거나 설정합니다.

Dock

부모 컨트롤에 도킹된 ToolStripItem 테두리를 가져오거나 설정하고 ToolStripItem이 부모와 함께 크기 조정되는 방법을 확인합니다.

DoubleClickEnabled

마우스를 두 번 클릭하여 ToolStripItem을 활성화할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

Enabled

ToolStripItem의 부모 컨트롤을 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

Events

Component에 연결된 이벤트 처리기의 목록을 가져옵니다.

(다음에서 상속됨 Component)
Font

항목에 표시되는 텍스트 글꼴을 가져오거나 설정합니다.

ForeColor

항목의 전경색을 가져오거나 설정합니다.

Height

ToolStripItem의 높이(픽셀)를 가져오거나 설정합니다.

Image

ToolStripItem에 표시되는 이미지를 가져오거나 설정합니다.

ImageAlign

ToolStripItem의 이미지 맞춤을 가져오거나 설정합니다.

ImageIndex

항목에 표시되는 이미지의 인덱스 값을 가져오거나 설정합니다.

ImageKey

ImageList에 표시되는 ToolStripItem에서 이미지의 키 접근자를 가져오거나 설정합니다.

ImageScaling

ToolStripItem에 있는 이미지의 크기가 컨테이너에 맞게 자동으로 조정되는지 여부를 나타내는 값을 가져오거나 설정합니다.

ImageTransparentColor

ToolStripItem 이미지에서 투명하게 처리할 색을 가져오거나 설정합니다.

IsDisposed

개체가 삭제되었는지 여부를 나타내는 값을 가져옵니다.

IsOnDropDown

현재 Control의 컨테이너가 ToolStripDropDown인지 여부를 나타내는 값을 가져옵니다.

IsOnOverflow

Placement 속성이 Overflow로 설정되었는지 여부를 나타내는 값을 가져옵니다.

Margin

항목과 인접 항목 사이의 간격을 가져오거나 설정합니다.

MergeAction

자식 메뉴가 부모 메뉴에 병합되는 방법을 가져오거나 설정합니다.

MergeIndex

현재 ToolStrip 안에 병합된 항목의 위치를 가져오거나 설정합니다.

Name

항목의 이름을 가져오거나 설정합니다.

Overflow

항목이 ToolStrip이나 ToolStripOverflowButton에 연결되었는지 아니면 둘 사이에 부동 상태로 있을 수 있는지 나타내는 값을 가져오거나 설정합니다.

Owner

이 항목의 소유자를 가져오거나 설정합니다.

OwnerItem

ToolStripItem의 부모 ToolStripItem를 가져옵니다.

Padding

항목의 내용과 가장자리 사이의 내부 간격(픽셀)을 가져오거나 설정합니다.

Parent

ToolStripItem의 부모 컨테이너를 가져오거나 설정합니다.

Placement

항목의 현재 레이아웃을 가져옵니다.

Pressed

항목이 누름 상태인지 여부를 나타내는 값을 가져옵니다.

RightToLeft

항목을 오른쪽에서 왼쪽으로 배치하고 텍스트를 오른쪽에서 왼쪽으로 쓸지 여부를 나타내는 값을 가져오거나 설정합니다.

RightToLeftAutoMirrorImage

ToolStripItem 속성이 RightToLeft로 설정된 경우 Yes 이미지를 자동으로 미러링합니다.

Selected

항목이 선택되었는지 여부를 나타내는 값을 가져옵니다.

ShowKeyboardCues

바로 가기 키를 표시할지 아니면 숨길지 나타내는 값을 가져옵니다.

Site

ComponentISite를 가져오거나 설정합니다.

(다음에서 상속됨 Component)
Size

항목의 크기를 가져오거나 설정합니다.

Tag

항목에 대한 데이터를 포함하는 개체를 가져오거나 설정합니다.

Text

항목에 표시되는 텍스트를 가져오거나 설정합니다.

TextAlign

ToolStripLabel의 텍스트 맞춤을 가져오거나 설정합니다.

TextDirection

ToolStripItem에 사용된 텍스트의 방향을 가져옵니다.

TextImageRelation

ToolStripItem 텍스트와 이미지의 서로 상대적인 위치를 가져오거나 설정합니다.

ToolTipText

컨트롤의 ToolTip으로 표시되는 텍스트를 가져오거나 설정합니다.

Visible

항목이 표시되는지 여부를 나타내는 값을 가져오거나 설정합니다.

Width

ToolStripItem의 너비(픽셀)를 가져오거나 설정합니다.

메서드

CreateAccessibilityInstance()

ToolStripItem에 대해 접근성 개체를 새로 만듭니다.

CreateObjRef(Type)

원격 개체와 통신하는 데 사용되는 프록시 생성에 필요한 모든 관련 정보가 들어 있는 개체를 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
Dispose()

Component에서 사용하는 모든 리소스를 해제합니다.

(다음에서 상속됨 Component)
Dispose(Boolean)

ToolStripItem에서 사용하는 관리되지 않는 리소스를 해제하고, 관리되는 리소스를 선택적으로 해제할 수 있습니다.

DoDragDrop(Object, DragDropEffects)

끌어서 놓기 작업을 시작합니다.

DoDragDrop(Object, DragDropEffects, Bitmap, Point, Boolean)

끌기 작업을 시작합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetCurrentParent()

현재 ToolStrip의 컨테이너인 ToolStripItem을 검색합니다.

GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 현재의 수명 서비스 개체를 검색합니다.

(다음에서 상속됨 MarshalByRefObject)
GetPreferredSize(Size)

컨트롤을 맞출 사각형 영역의 크기를 가져옵니다.

GetService(Type)

Component 또는 해당 Container에서 제공하는 서비스를 나타내는 개체를 반환합니다.

(다음에서 상속됨 Component)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
InitializeLifetimeService()
사용되지 않음.

이 인스턴스의 수명 정책을 제어하는 수명 서비스 개체를 가져옵니다.

(다음에서 상속됨 MarshalByRefObject)
Invalidate()

ToolStripItem의 전체 화면을 무효화하고 다시 그립니다.

Invalidate(Rectangle)

다음 그리기 작업에서 다시 그릴 영역인 ToolStripItem의 업데이트 영역에 ToolStripItem의 지정된 영역을 추가하여 무효화하고 ToolStripItem에 그리기 메시지를 보냅니다.

IsInputChar(Char)

문자가 항목에서 인식하는 입력 문자인지 여부를 확인합니다.

IsInputKey(Keys)

지정된 키가 일반 입력 키인지 또는 전처리가 필요한 특수 키인지를 확인합니다.

MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
MemberwiseClone(Boolean)

현재 MarshalByRefObject 개체의 단순 복사본을 만듭니다.

(다음에서 상속됨 MarshalByRefObject)
OnAvailableChanged(EventArgs)

AvailableChanged 이벤트를 발생시킵니다.

OnBackColorChanged(EventArgs)

BackColorChanged 이벤트를 발생시킵니다.

OnBindingContextChanged(EventArgs)

BindingContextChanged 이벤트를 발생시킵니다.

(다음에서 상속됨 BindableComponent)
OnBoundsChanged()

Bounds 속성이 변경되면 발생합니다.

OnClick(EventArgs)

Click 이벤트를 발생시킵니다.

OnCommandCanExecuteChanged(EventArgs)

CommandCanExecuteChanged 이벤트를 발생시킵니다.

OnCommandChanged(EventArgs)

CommandChanged 이벤트를 발생시킵니다.

OnCommandParameterChanged(EventArgs)

CommandParameterChanged 이벤트를 발생시킵니다.

OnDisplayStyleChanged(EventArgs)

DisplayStyleChanged 이벤트를 발생시킵니다.

OnDoubleClick(EventArgs)

DoubleClick 이벤트를 발생시킵니다.

OnDragDrop(DragEventArgs)

DragDrop 이벤트를 발생시킵니다.

OnDragEnter(DragEventArgs)

DragEnter 이벤트를 발생시킵니다.

OnDragLeave(EventArgs)

DragLeave 이벤트를 발생시킵니다.

OnDragOver(DragEventArgs)

DragOver 이벤트를 발생시킵니다.

OnEnabledChanged(EventArgs)

EnabledChanged 이벤트를 발생시킵니다.

OnFontChanged(EventArgs)

FontChanged 이벤트를 발생시킵니다.

OnForeColorChanged(EventArgs)

ForeColorChanged 이벤트를 발생시킵니다.

OnGiveFeedback(GiveFeedbackEventArgs)

GiveFeedback 이벤트를 발생시킵니다.

OnLayout(LayoutEventArgs)

Layout 이벤트를 발생시킵니다.

OnLocationChanged(EventArgs)

LocationChanged 이벤트를 발생시킵니다.

OnMouseDown(MouseEventArgs)

MouseDown 이벤트를 발생시킵니다.

OnMouseEnter(EventArgs)

MouseEnter 이벤트를 발생시킵니다.

OnMouseHover(EventArgs)

MouseHover 이벤트를 발생시킵니다.

OnMouseLeave(EventArgs)

MouseLeave 이벤트를 발생시킵니다.

OnMouseMove(MouseEventArgs)

MouseMove 이벤트를 발생시킵니다.

OnMouseUp(MouseEventArgs)

MouseUp 이벤트를 발생시킵니다.

OnOwnerChanged(EventArgs)

OwnerChanged 이벤트를 발생시킵니다.

OnOwnerFontChanged(EventArgs)

FontChanged의 부모에서 Font 속성이 변경되면 ToolStripItem 이벤트를 발생시킵니다.

OnPaint(PaintEventArgs)

Paint 이벤트를 발생시킵니다.

OnParentBackColorChanged(EventArgs)

BackColorChanged 이벤트를 발생시킵니다.

OnParentChanged(ToolStrip, ToolStrip)

ParentChanged 이벤트를 발생시킵니다.

OnParentEnabledChanged(EventArgs)

항목 컨테이너의 EnabledChanged 속성 값이 변경되면 Enabled 이벤트를 발생시킵니다.

OnParentForeColorChanged(EventArgs)

ForeColorChanged 이벤트를 발생시킵니다.

OnParentRightToLeftChanged(EventArgs)

RightToLeftChanged 이벤트를 발생시킵니다.

OnQueryContinueDrag(QueryContinueDragEventArgs)

QueryContinueDrag 이벤트를 발생시킵니다.

OnRequestCommandExecute(EventArgs)

컨텍스트에서 허용하는 경우 를 호출하기 위해 의 OnClick(EventArgs) 컨텍스트에서 호출 Execute(Object) 됩니다.

OnRightToLeftChanged(EventArgs)

RightToLeftChanged 이벤트를 발생시킵니다.

OnSelectedChanged(EventArgs)

ToolStrip 또는 ToolStripDropDown에 포함될 수 있는 모든 요소의 이벤트와 레이아웃을 관리하는 추상 기본 클래스를 나타냅니다.

OnTextChanged(EventArgs)

TextChanged 이벤트를 발생시킵니다.

OnVisibleChanged(EventArgs)

VisibleChanged 이벤트를 발생시킵니다.

PerformClick()

ToolStripItem에 대한 Click 이벤트를 생성합니다.

ProcessCmdKey(Message, Keys)

명령 키를 처리합니다.

ProcessDialogKey(Keys)

대화 상자 키를 처리합니다.

ProcessMnemonic(Char)

니모닉 문자를 처리합니다.

ResetBackColor()

이 메서드는 이 클래스와 관련이 없습니다.

ResetDisplayStyle()

이 메서드는 이 클래스와 관련이 없습니다.

ResetFont()

이 메서드는 이 클래스와 관련이 없습니다.

ResetForeColor()

이 메서드는 이 클래스와 관련이 없습니다.

ResetImage()

이 메서드는 이 클래스와 관련이 없습니다.

ResetMargin()

이 메서드는 이 클래스와 관련이 없습니다.

ResetPadding()

이 메서드는 이 클래스와 관련이 없습니다.

ResetRightToLeft()

이 메서드는 이 클래스와 관련이 없습니다.

ResetTextDirection()

이 메서드는 이 클래스와 관련이 없습니다.

Select()

항목을 선택합니다.

SetBounds(Rectangle)

항목의 크기와 위치를 설정합니다.

SetVisibleCore(Boolean)

ToolStripItem을 지정된 표시 상태로 설정합니다.

ToString()

Component의 이름이 포함된 String을 반환합니다(있는 경우). 이 메서드는 재정의할 수 없습니다.

이벤트

AvailableChanged

Available 속성 값이 변경되면 발생합니다.

BackColorChanged

BackColor 속성 값이 변경되면 발생합니다.

BindingContextChanged

바인딩 컨텍스트가 변경되면 발생합니다.

(다음에서 상속됨 BindableComponent)
Click

ToolStripItem을 클릭하면 발생합니다.

CommandCanExecuteChanged

속성에 CanExecute(Object) 할당된 CommandICommand 상태 변경된 경우에 발생합니다.

CommandChanged

속성의 할당 ICommandCommand 변경되면 발생합니다.

CommandParameterChanged

CommandParameter 속성 값이 변경되면 발생합니다.

DisplayStyleChanged

DisplayStyle가 변경될 때 발생합니다.

Disposed

Dispose() 메서드를 호출하여 구성 요소를 삭제할 때 발생합니다.

(다음에서 상속됨 Component)
DoubleClick

항목을 마우스로 두 번 클릭하면 발생합니다.

DragDrop

사용자가 항목을 끌어 이 항목에 해당 항목을 놓도록 마우스를 놓을 때 발생합니다.

DragEnter

사용자가 이 항목의 클라이언트 영역으로 항목을 끌 때 발생합니다.

DragLeave

사용자가 항목을 끌어 마우스 포인터가 이 항목의 클라이언트 영역에서 벗어날 때 발생합니다.

DragOver

사용자가 이 항목의 클라이언트 영역 위로 항목을 끌 때 발생합니다.

EnabledChanged

Enabled 속성 값이 변경되면 발생합니다.

ForeColorChanged

ForeColor 속성 값이 변경되면 발생합니다.

GiveFeedback

끌기 작업을 수행하는 동안 발생합니다.

LocationChanged

ToolStripItem의 위치가 업데이트되면 발생합니다.

MouseDown

마우스 포인터가 항목 위에 있을 때 마우스 단추를 클릭하면 발생합니다.

MouseEnter

마우스 포인터가 항목에 진입하면 발생합니다.

MouseHover

마우스 포인터로 항목을 가리키면 발생합니다.

MouseLeave

마우스 포인터가 항목을 벗어나면 발생합니다.

MouseMove

마우스 포인터를 항목 위로 이동하면 발생합니다.

MouseUp

마우스 포인터가 항목 위에 있을 때 마우스 단추를 놓으면 발생합니다.

OwnerChanged

Owner 속성이 변경되면 발생합니다.

Paint

항목을 다시 그리면 발생합니다.

QueryAccessibilityHelp

내게 필요한 옵션 지원 클라이언트 애플리케이션에서 ToolStripItem에 대한 도움말을 호출하면 발생합니다.

QueryContinueDrag

끌어서 놓기 작업 중에 발생하며 끌기 소스가 끌어서 놓기 작업을 취소해야 할지 여부를 결정하도록 합니다.

RightToLeftChanged

RightToLeft 속성 값이 변경되면 발생합니다.

SelectedChanged

ToolStrip 또는 ToolStripDropDown에 포함될 수 있는 모든 요소의 이벤트와 레이아웃을 관리하는 추상 기본 클래스를 나타냅니다.

TextChanged

Text 속성 값이 변경되면 발생합니다.

VisibleChanged

Visible 속성 값이 변경되면 발생합니다.

명시적 인터페이스 구현

IDropTarget.OnDragDrop(DragEventArgs)

DragDrop 이벤트를 발생시킵니다.

IDropTarget.OnDragEnter(DragEventArgs)

DragEnter 이벤트를 발생시킵니다.

IDropTarget.OnDragLeave(EventArgs)

DragLeave 이벤트를 발생시킵니다.

IDropTarget.OnDragOver(DragEventArgs)

DragOver 이벤트를 발생시킵니다.

적용 대상

추가 정보