Export (0) Print
Expand All

ToolStripItem.IsOnDropDown Property

Gets a value indicating whether the container of the current Control is a ToolStripDropDown.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

<BrowsableAttribute(False)> _
Public ReadOnly Property IsOnDropDown As Boolean

Property Value

Type: System.Boolean
true if the container of the current Control is a ToolStripDropDown; otherwise, false.

The following code example demonstrates how to use the IsOnDropDown property. 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 Overrides Sub OnPaint(e As PaintEventArgs)

   If (Me.Owner IsNot Nothing) Then 
      ' Find the dimensions of the image and the text  
      ' areas of the item.  

      ' 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)

      ' Draw the item's image.  
      Dim irea As New ToolStripItemImageRenderEventArgs(e.Graphics, Me, imageRect)

      ' 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, _
   End If 
 End Sub

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft