Form.AutoScroll Propriedade

Definição

Recebe ou define um valor que indica se o formulário permite o autoscrolling.

public:
 virtual property bool AutoScroll { bool get(); void set(bool value); };
public override bool AutoScroll { get; set; }
member this.AutoScroll : bool with get, set
Public Overrides Property AutoScroll As Boolean

Valor de Propriedade

true para ativar o autoscroll no formulário; caso contrário, false. A predefinição é false.

Exemplos

O exemplo seguinte demonstra como usar a AutoScroll propriedade para permitir a visualização de controlos que excedem a área do cliente de um formulário. O exemplo cria um novo formulário e adiciona um Button controlo ao formulário. O Button controlo está posicionado fora do tamanho da área do cliente do novo formulário. A AutoScroll propriedade está definida como true para mostrar as barras de scroll no formulário, permitindo ao utilizador deslocar-se até ao controlo. Este exemplo exige que o método definido neste exemplo seja chamado a partir de outra forma num gestor de eventos ou outro método.

private:
   void DisplayMyScrollableForm()
   {
      // Create a new form.
      Form^ form2 = gcnew Form;

      // Create a button to add to the new form.
      Button^ button1 = gcnew Button;

      // Set text for the button.
      button1->Text = "Scrolled Button";

      // Set the size of the button.
      button1->Size = System::Drawing::Size( 100, 30 );

      // Set the location of the button to be outside the form's client area.
      button1->Location = Point(form2->Size.Width + 200,form2->Size.Height + 200);

      // Add the button control to the new form.
      form2->Controls->Add( button1 );

      // Set the AutoScroll property to true to provide scrollbars.
      form2->AutoScroll = true;

      // Display the new form as a dialog box.
      form2->ShowDialog();
   }
private void DisplayMyScrollableForm()
{
   // Create a new form.
   Form form2 = new Form();
   // Create a button to add to the new form.
   Button button1 = new Button();
   // Set text for the button.
   button1.Text = "Scrolled Button";
   // Set the size of the button.
   button1.Size = new Size(100,30);
   // Set the location of the button to be outside the form's client area.
   button1.Location = new Point(form2.Size.Width + 200, form2.Size.Height + 200);

   // Add the button control to the new form.
   form2.Controls.Add(button1);
   // Set the AutoScroll property to true to provide scrollbars.
   form2.AutoScroll = true;

   // Display the new form as a dialog box.
   form2.ShowDialog();
}
Private Sub DisplayMyScrollableForm()
   ' Create a new form.
   Dim form2 As New Form()
   ' Create a button to add to the new form.
   Dim button1 As New Button()
   ' Set text for the button.
   button1.Text = "Scrolled Button"
   ' Set the size of the button.
   button1.Size = New Size(100, 30)
   ' Set the location of the button to be outside the form's client area.
   button1.Location = New Point(form2.Size.Width + 200, form2.Size.Height + 200)

   ' Add the button control to the new form.
   form2.Controls.Add(button1)
   ' Set the AutoScroll property to true to provide scrollbars.
   form2.AutoScroll = True

   ' Display the new form as a dialog box.
   form2.ShowDialog()
End Sub

Observações

Se esta propriedade estiver definida para true, barras de deslocamento são exibidas no formulário se houver controlos fora da região cliente do formulário. Além disso, quando o autoscrolling está ativado, a área do cliente do formulário desloca-se automaticamente para tornar visível o controlo com foco de entrada.

Pode usar esta propriedade para evitar que os utilizadores percam a capacidade de visualizar os controlos quando as definições de resolução de vídeo estão definidas para uma resolução baixa.

Aplica-se a