ToolStripItem 클래스

정의

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

public ref class ToolStripItem abstract : System::ComponentModel::Component, IDisposable, System::Windows::Forms::IDropTarget
public abstract class ToolStripItem : System.ComponentModel.Component, IDisposable, System.Windows.Forms.IDropTarget
type ToolStripItem = class
    inherit Component
    interface IDropTarget
    interface IComponent
    interface IDisposable
Public MustInherit Class ToolStripItem
Inherits Component
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 단추, 콤보 상자, 텍스트 상자 또는 ToolStrip 컨트롤 또는 Windows 바로 가기 메뉴와 유사한 ToolStripDropDown 컨트롤에 포함할 수 있는 레이블과 같은 요소입니다. 클래스는 ToolStrip 이러한 요소에 대한 끌어서 놓기 입력을 포함하여 그리기 및 키보드 및 ToolStripItem 마우스 입력을 관리하고, 클래스는 요소 자체 내에서 이벤트 및 레이아웃을 관리합니다.

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

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

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

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

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

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

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

ToolStripProgressBar StatusStrip 포함된 Windows 진행률 표시줄 컨트롤을 나타냅니다.
ToolStripDropDownItem 를 호스팅하는 A ToolStripItemToolStripMenuItemToolStripSplitButton및 .ToolStripDropDownButton

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

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

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

생성자

Name Description
ToolStripItem()

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

ToolStripItem(String, Image, EventHandler, String)

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

ToolStripItem(String, Image, EventHandler)

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

속성

Name Description
AccessibilityObject

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

AccessibleDefaultActionDescription

접근성 클라이언트 애플리케이션에서 사용할 컨트롤의 기본 작업 설명을 가져오거나 설정합니다.

AccessibleDescription

접근성 클라이언트 애플리케이션에 보고될 설명을 가져오거나 설정합니다.

AccessibleName

접근성 클라이언트 애플리케이션에서 사용할 컨트롤의 이름을 가져오거나 설정합니다.

AccessibleRole

컨트롤의 사용자 인터페이스 요소 유형을 지정하는 액세스 가능한 컨트롤 역할을 가져오거나 설정합니다.

Alignment

항목이 시작 또는 끝에 ToolStrip맞춰지는지 여부를 나타내는 값을 가져오거나 설정합니다.

AllowDrop

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

Anchor

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

AutoSize

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

AutoToolTip

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

Available

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

BackColor

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

BackgroundImage

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

BackgroundImageLayout

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

Bounds

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

CanRaiseEvents

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

(다음에서 상속됨 Component)
CanSelect

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

Container

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

(다음에서 상속됨 Component)
ContentRectangle

텍스트 및 아이콘과 같은 콘텐츠를 배경 테두리를 덮어쓰지 않고 배치할 수 있는 ToolStripItem 영역을 가져옵니다.

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

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

IsOnOverflow

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

Margin

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

MergeAction

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

MergeIndex

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

Name

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

Overflow

항목이 둘 사이에 연결되어 ToolStripToolStripOverflowButton 있는지 또는 부동 소수점 사이의 부동 소수점인지를 가져오거나 설정합니다.

Owner

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

OwnerItem

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

Padding

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

Parent

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

Placement

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

Pressed

항목의 상태를 눌렀는지 여부를 나타내는 값을 가져옵니다.

RightToLeft

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

RightToLeftAutoMirrorImage

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

Selected

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

ShowKeyboardCues

바로 가기 키를 표시하거나 숨길지 여부를 나타내는 값을 가져옵니다.

Site

ISite를 가져오거나 Component의 값을 설정합니다.

(다음에서 상속됨 Component)
Size

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

Tag

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

Text

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

TextAlign

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

TextDirection

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

TextImageRelation

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

ToolTipText

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

Visible

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

Width

너비를 픽셀 ToolStripItem단위로 가져오거나 설정합니다.

메서드

Name Description
CreateAccessibilityInstance()

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

CreateObjRef(Type)

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

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

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

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

관리되지 않는 리소스를 ToolStripItem 해제하고 관리되는 리소스를 선택적으로 해제합니다.

DoDragDrop(Object, DragDropEffects)

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

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)

지정한 영역을 다음 페인트 작업에서 다시 칠할 영역인 업데이트 영역에 추가하여 지정한 영역을 ToolStripItemToolStripItem무효화하고 페인트 메시지를 해당 영역으로 ToolStripItem보냅니다.

IsInputChar(Char)

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

IsInputKey(Keys)

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

MemberwiseClone()

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

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

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

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

AvailableChanged 이벤트를 발생합니다.

OnBackColorChanged(EventArgs)

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

OnBoundsChanged()

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

OnClick(EventArgs)

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

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 이벤트를 발생시킵니다.

OnRightToLeftChanged(EventArgs)

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

OnTextChanged(EventArgs)

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

OnVisibleChanged(EventArgs)

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

PerformClick()

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

ProcessCmdKey(Message, Keys)

명령 키를 처리합니다.

ProcessDialogKey(Keys)

대화 상자를 처리합니다.

ProcessMnemonic(Char)

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

ResetBackColor()

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

ResetDisplayStyle()

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

ResetFont()

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

ResetForeColor()

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

ResetImage()

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

ResetMargin()

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

ResetPadding()

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

ResetRightToLeft()

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

ResetTextDirection()

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

Select()

항목을 선택합니다.

SetBounds(Rectangle)

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

SetVisibleCore(Boolean)

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

ToString()

String(있는 경우)의 Component이름을 포함하는 값을 반환합니다. 이 메서드는 재정의해서는 안 됩니다.

이벤트

Name Description
AvailableChanged

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

BackColorChanged

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

Click

클릭할 ToolStripItem 때 발생합니다.

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 발생합니다.

TextChanged

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

VisibleChanged

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

명시적 인터페이스 구현

Name Description
IDropTarget.OnDragDrop(DragEventArgs)

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

IDropTarget.OnDragEnter(DragEventArgs)

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

IDropTarget.OnDragLeave(EventArgs)

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

IDropTarget.OnDragOver(DragEventArgs)

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

적용 대상

추가 정보