共用方式為


Form.AutoScroll 屬性

定義

取得或設定值,指出表單是否啟用自動捲動。

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

屬性值

Boolean

true 表示要啟用表單上的自動捲動,否則為 false。 預設為 false

範例

下列範例示範如何使用 AutoScroll 屬性來啟用表單工作區的控制項顯示。 此範例會建立新的表單,並將控制項新增 Button 至表單。 控制項 Button 的位置會放大新表單的工作區。 屬性 AutoScroll 設定為 true,以顯示表單上的捲軸,讓使用者捲動至控制項。 這個範例需要從事件處理常式或其他方法的另一個表單呼叫在此範例中定義的方法。

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

備註

如果此屬性設定 true 為 ,則如果任何控制項位於表單的用戶端區域外,捲軸就會顯示在表單上。 此外,當自動註冊開啟時,表單的工作區會自動捲動,讓控制項顯示輸入焦點。

您可以使用這個屬性來防止使用者在視訊解析度設定設為低解析度時失去檢視控制項的能力。

適用於