ScrollableControl.SetAutoScrollMargin-Methode
Legt die Größe der AutoBildlaufränder fest.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Syntax
'Declaration
Public Sub SetAutoScrollMargin ( _
x As Integer, _
y As Integer _
)
'Usage
Dim instance As ScrollableControl
Dim x As Integer
Dim y As Integer
instance.SetAutoScrollMargin(x, y)
public void SetAutoScrollMargin (
int x,
int y
)
public:
void SetAutoScrollMargin (
int x,
int y
)
public void SetAutoScrollMargin (
int x,
int y
)
public function SetAutoScrollMargin (
x : int,
y : int
)
Parameter
- x
Der Width-Wert.
- y
Der Height-Wert.
Hinweise
Der Rand legt Breite und Höhe des Rahmens für alle Steuerelemente fest. Mit diesem Rand wird festgelegt, wann Bildlaufleisten für den Container benötigt werden und zu welcher Position ein Bildlauf durchzuführen ist, wenn ein Steuerelement ausgewählt wird.
Hinweis
Wenn eine negative Zahl als x-Wert oder y-Wert übergeben wird, wird der Wert auf 0 (null) zurückgesetzt.
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 das Beispiel ist es erforderlich, dass Sie eine Instanz von einem Panel-Steuerelement, TextBox und Button erstellt haben. Platzieren Sie das Feld 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 MySub()
' 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 MySub()
{
/* 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 MySub()
{
/* 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 MySub()
{
/* 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);
}
}
} //MySub
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
Siehe auch
Referenz
ScrollableControl-Klasse
ScrollableControl-Member
System.Windows.Forms-Namespace
AutoScrollMargin
AutoScroll
AutoScrollMinSize