ScrollBarRenderer.DrawArrowButton Méthode

Définition

Dessine une flèche de défilement avec les styles visuels.

C#
public static void DrawArrowButton (System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.VisualStyles.ScrollBarArrowButtonState state);

Paramètres

g
Graphics

Graphics utilisé pour dessiner la flèche de défilement.

bounds
Rectangle

Rectangle qui spécifie les limites de la flèche de défilement.

state
ScrollBarArrowButtonState

Une des valeurs ScrollBarArrowButtonState qui spécifie l'état visuel de la flèche de défilement.

Exceptions

Le système d'exploitation ne prend pas en charge les styles visuels.

  • ou -

Les styles visuels sont désactivés par l'utilisateur dans le système d'exploitation.

  • ou -

Les styles visuels ne sont pas appliqués à la zone client des fenêtres d'application.

Exemples

L’exemple de code suivant utilise la méthode dans la DrawArrowButton méthode d’un OnPaint contrôle personnalisé pour dessiner une flèche de défilement dans l’état déterminé par l’emplacement du pointeur de la souris. Cet exemple de code fait partie d’un exemple plus grand fourni pour la ScrollBarRenderer classe.

C#
// Draw the scroll bar in its normal state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    // Visual styles are not enabled.
    if (!ScrollBarRenderer.IsSupported)
    {
        this.Parent.Text = "CustomScrollBar Disabled";
        return;
    }

    this.Parent.Text = "CustomScrollBar Enabled";

    // Draw the scroll bar track.
    ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
        ClientRectangle, ScrollBarState.Normal);

    // Draw the thumb and thumb grip in the current state.
    ScrollBarRenderer.DrawHorizontalThumb(e.Graphics,
        thumbRectangle, thumbState);
    ScrollBarRenderer.DrawHorizontalThumbGrip(e.Graphics,
        thumbRectangle, thumbState);

    // Draw the scroll arrows in the current state.
    ScrollBarRenderer.DrawArrowButton(e.Graphics,
            leftArrowRectangle, leftButtonState);
    ScrollBarRenderer.DrawArrowButton(e.Graphics,
            rightArrowRectangle, rightButtonState);

    // Draw a highlighted rectangle in the left side of the scroll 
    // bar track if the user has clicked between the left arrow 
    // and thumb.
    if (leftBarClicked)
    {
        clickedBarRectangle.X = thumbLeftLimit;
        clickedBarRectangle.Width = thumbRectangle.X - thumbLeftLimit;
        ScrollBarRenderer.DrawLeftHorizontalTrack(e.Graphics,
            clickedBarRectangle, ScrollBarState.Pressed);
    }

    // Draw a highlighted rectangle in the right side of the scroll 
    // bar track if the user has clicked between the right arrow 
    // and thumb.
    else if (rightBarClicked)
    {
        clickedBarRectangle.X =
            thumbRectangle.X + thumbRectangle.Width;
        clickedBarRectangle.Width =
            thumbRightLimitRight - clickedBarRectangle.X;
        ScrollBarRenderer.DrawRightHorizontalTrack(e.Graphics,
            clickedBarRectangle, ScrollBarState.Pressed);
    }
}

Remarques

Avant d’utiliser cette méthode, vous devez vérifier que la IsSupported propriété retourne true.

S’applique à

Produit Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7