ToolStripItem.Owner Özellik

Tanım

Bu öğenin sahibini alır veya ayarlar.

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; }
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.ToolStrip? Owner { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.Owner : System.Windows.Forms.ToolStrip with get, set
Public Property Owner As ToolStrip

Özellik Değeri

öğesinin ToolStrip sahibi veya olan, öğesine sahip olmaktır ToolStripItem.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, özel işleme için özelliğinin Owner nasıl kullanılacağını gösterir. Bu kod örneği, sınıfı için ToolStripItem sağlanan daha büyük bir örneğin parçasıdır.

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

Açıklamalar

OwnerToolStrip, Items koleksiyonu geçerli ToolStripItemöğesini içeren öğesini döndürür. Bu, taşmayı işlemek için özel kod yazmadan en üst düzeydeki ToolStrip veya diğer özelliklere başvurmanın ImageList en iyi yoludur.

öğesi Owner içine ToolStripOverflowdüşse bile aynı kalır. , Owner koleksiyonda olan ancak koleksiyonda DisplayedItems olmayan Items belirli öğeler için olabilirnull.

Şunlara uygulanır