ScrollableControl.SetAutoScrollMargin(Int32, Int32) Metod

Definition

Anger storleken på marginalerna för automatisk rullning.

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)

Parametrar

x
Int32

Värdet Width.

y
Int32

Värdet Height.

Exempel

I följande kodexempel används den härledda klassen , Panel. Exemplet utvärderar platsen för en textruta och ändrar utseendet och beteendet för den överordnade containern, panelkontrollen. Exemplet kräver att du har skapat en instans av en Panel kontroll, TextBox, och Button. Placera rutan på panelen så att den överlappar minst en av panelens kanter. Anropa den här underproceduren genom att klicka på en knapp för att se skillnaden i panelens beteende och utseende.

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

Kommentarer

Marginalen anger bredden och höjden på kantlinjen runt varje kontroll. Den här marginalen används för att avgöra när rullningslister behövs i containern och var du ska rulla till när en kontroll väljs.

Note

Om ett negativt tal skickas som x värden eller y återställs värdet till 0.

Gäller för

Se även