Freigeben über


ScrollableControl.AutoScroll-Eigenschaft

Ruft einen Wert ab, der angibt, ob im Container ein Bildlauf zu allen Steuerelementen möglich ist, die sich außerhalb des sichtbaren Bereichs des Containers befinden, oder legt diesen Wert fest.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
<LocalizableAttribute(True)> _
Public Overridable Property AutoScroll As Boolean
'Usage
Dim instance As ScrollableControl
Dim value As Boolean

value = instance.AutoScroll

instance.AutoScroll = value
[LocalizableAttribute(true)] 
public virtual bool AutoScroll { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property bool AutoScroll {
    bool get ();
    void set (bool value);
}
/** @property */
public boolean get_AutoScroll ()

/** @property */
public void set_AutoScroll (boolean value)
public function get AutoScroll () : boolean

public function set AutoScroll (value : boolean)

Eigenschaftenwert

true, wenn im Container ein automatischer Bildlauf möglich ist, andernfalls false. Der Standardwert ist false.

Hinweise

Wenn true, kann der Container aufgrund dieser Eigenschaft eine virtuelle Größe aufweisen, die größer als der sichtbare Bereich ist.

Beispiel

Im folgenden Codebeispiel wird die abgeleitete Klasse Panel verwendet. Im Beispiel wird die Position eines Textfelds ausgewertet und die Darstellung sowie das Verhalten des übergeordneten Containers, also des Auswahlbereich-Steuerelements, geändert. Für dieses Beispiels wird vorausgesetzt, dass Sie Instanzen eines Panel-Steuerelements sowie von TextBox und Button erstellt haben. Platzieren Sie das Textfeld so im Auswahlbereich, dass dieses mindestens eine Seite des Bereichs überlappt. Rufen Sie diese Unterprozedur durch Klicken auf eine Schaltfläche auf, um den Unterschied in Verhalten und Darstellung des Auswahlbereichs zu erkennen.

Private Sub SetAutoScrollMargins()
    ' If the text box is outside the panel's bounds,
    ' turn on auto-scrolling and set the margin. 
    If (text1.Location.X > panel1.Location.X) Or _
        (text1.Location.Y > panel1.Location.Y) Then
        panel1.AutoScroll = True
        ' If the AutoScrollMargin is set to less
        ' than (5,5), set it to 5,5. 
        If (panel1.AutoScrollMargin.Width < 5) Or _
            (panel1.AutoScrollMargin.Height < 5) Then
            
            panel1.SetAutoScrollMargin(5, 5)
        End If
    End If
End Sub
private void SetAutoScrollMargins()
 {
    /* If the text box is outside the panel's bounds, 
       turn on auto-scrolling and set the margin. */  
    if (text1.Location.X > panel1.Location.X || 
       text1.Location.Y > panel1.Location.Y)
    {
       panel1.AutoScroll = true;
       /* If the AutoScrollMargin is set to less 
          than (5,5), set it to 5,5. */
       if( panel1.AutoScrollMargin.Width < 5 || 
          panel1.AutoScrollMargin.Height < 5)
       {
          panel1.SetAutoScrollMargin(5, 5);
       }
    }
 }
 
void SetAutoScrollMargins()
{
   /* If the text box is outside the panel's bounds, 
          turn on auto-scrolling and set the margin. */
   if ( text1->Location.X > panel1->Location.X || text1->Location.Y > panel1->Location.Y )
   {
      panel1->AutoScroll = true;

      /* If the AutoScrollMargin is set to less 
                than (5,5), set it to 5,5. */
      if ( panel1->AutoScrollMargin.Width < 5 || panel1->AutoScrollMargin.Height < 5 )
      {
         panel1->SetAutoScrollMargin( 5, 5 );
      }
   }
}
private void SetAutoScrollMargins()
{
    /* If the text box is outside the panel's bounds, 
       turn on auto-scrolling and set the margin. */
    if (text1.get_Location().get_X() > panel1.get_Location().get_X() 
        || text1.get_Location().get_Y() > panel1.get_Location().get_Y()) {
        
        panel1.set_AutoScroll(true);

        /* If the AutoScrollMargin is set to less 
           than (5,5), set it to 5,5. */
        if (panel1.get_AutoScrollMargin().get_Width() < 5 
            || panel1.get_AutoScrollMargin().get_Height() < 5) {
                panel1.SetAutoScrollMargin(5, 5);
        }
    }
} //SetAutoScrollMargins

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

ScrollableControl-Klasse
ScrollableControl-Member
System.Windows.Forms-Namespace
GetScrollState
SetScrollState
AutoScrollMargin
AutoScrollPosition
VerticalScroll
HorizontalScroll
AdjustFormScrollbars
ScrollToControl