ToolStripItem.IsOnDropDown 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 Control의 컨테이너가 ToolStripDropDown인지 여부를 나타내는 값을 가져옵니다.
public:
property bool IsOnDropDown { bool get(); };
[System.ComponentModel.Browsable(false)]
public bool IsOnDropDown { get; }
[<System.ComponentModel.Browsable(false)>]
member this.IsOnDropDown : bool
Public ReadOnly Property IsOnDropDown As Boolean
속성 값
현재 Control의 컨테이너가 ToolStripDropDown이면 true
이고, 그렇지 않으면 false
입니다.
- 특성
예제
다음 코드 예제를 사용 하는 방법에 설명 합니다 IsOnDropDown 속성입니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ToolStripItem 클래스입니다.
// 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