ScrollableControl.SetAutoScrollMargin(Int32, Int32) Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Legt die Größe der Ränder für den automatischen Bildlauf fest.
public:
void SetAutoScrollMargin(int x, int y);
public void SetAutoScrollMargin(int x, int y);
member this.SetAutoScrollMargin : int * int -> unit
Public Sub SetAutoScrollMargin (x As Integer, y As Integer)
Parameter
Beispiele
Im folgenden Codebeispiel wird die abgeleitete Klasse verwendet. Panel Das Beispiel wertet die Position eines Textfelds aus und ändert das Erscheinungsbild und Verhalten des übergeordneten Containers, dem Panel-Steuerelement. Das Beispiel erfordert, dass Sie eine Instanz eines Panel Steuerelements TextBox, und Button. Platzieren Sie das Feld auf dem Panel, sodass es mindestens eine der Ränder des Panels überlappt. Rufen Sie diese Unterprozedur beim Klicken auf eine Schaltfläche auf, um den Unterschied im Verhalten und der Darstellung des Panels anzuzeigen.
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.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 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
Hinweise
Der Rand legt die Breite und Höhe des Rahmens um jedes Steuerelement fest. Dieser Rand wird verwendet, um zu bestimmen, wann Bildlaufleisten im Container erforderlich sind und wohin ein Bildlauf ausgeführt werden soll, wenn ein Steuerelement ausgewählt ist.
Note
Wenn eine negative Zahl als die x Werte y übergeben wird, wird der Wert auf 0 zurückgesetzt.