ToolStripItem.Owner 속성

정의

이 항목의 소유자를 가져오거나 설정합니다.Gets or sets the owner of this item.

public:
 property System::Windows::Forms::ToolStrip ^ Owner { System::Windows::Forms::ToolStrip ^ get(); void set(System::Windows::Forms::ToolStrip ^ value); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.ToolStrip Owner { get; set; }
member this.Owner : System.Windows.Forms.ToolStrip with get, set
Public Property Owner As ToolStrip

속성 값

ToolStrip을 소유하거나 소유할 ToolStripItem입니다.The ToolStrip that owns or is to own the ToolStripItem.

특성

예제

다음 코드 예제를 사용 하는 방법에 설명 합니다 Owner 속성 사용자 지정 렌더링 합니다.The following code example demonstrates how to use the Owner property for custom rendering. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripItem 클래스입니다.This code example is part of a larger example provided for the ToolStripItem class.

// 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 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

설명

Owner 반환 된 ToolStrip 해당 항목 컬렉션에 현재 포함 되어 ToolStripItem.Owner returns the ToolStrip whose Items collection contains the current ToolStripItem. 이 참조 하는 가장 좋은 방법은 ImageList 또는 기타 속성 최상위 ToolStrip 오버플로 처리 하는 특수 코드를 작성 하지 않고도 합니다.This is the best way to reference ImageList or other properties in the top-level ToolStrip without writing special code to handle overflow.

합니다 Owner 항목에 해당 하는 경우에 동일 하 게 유지 합니다 ToolStripOverflow합니다.The Owner remains the same even if the item falls into the ToolStripOverflow. Owner 될 수 있습니다 null 에 있는 요소에 대 한 특정 합니다 DisplayedItems 컬렉션 되지 않습니다는 Items 컬렉션입니다.The Owner can be null for certain elements that are in the DisplayedItems collection but not in the Items collection.

적용 대상