Form.AutoScroll プロパティ
フォームで自動スクロールを有効にするかどうかを示す値を取得または設定します。
Overrides Public Property AutoScroll As Boolean
[C#]
public override bool AutoScroll {get; set;}
[C++]
public: __property bool get_AutoScroll();public: __property void set_AutoScroll(bool);
[JScript]
public override function get AutoScroll() : Boolean;public override function set AutoScroll(Boolean);
プロパティ値
フォームで自動スクロールを有効にする場合は true 。それ以外の場合は false 。既定値は true です。
解説
このプロパティが true に設定された場合、フォームのクライアント領域外に配置されたコントロールがあると、スクロール バーが表示されます。また、自動スクロールが有効な場合、入力フォーカスを持つコントロールが表示されるように、フォームのクライアント領域が自動的にスクロールします。
このプロパティを使用すると、ビデオ解像度が低い値に設定されている場合でも、コントロールを表示できないという事態を避けることができます。
使用例
[Visual Basic, C#, C++] AutoScroll プロパティを使用して、フォームのクライアント領域より大きいコントロールの表示を有効にする方法を次の例に示します。この例では、新しいフォームを作成し、そのフォームに Button コントロールを追加します。この Button コントロールのサイズは、作成した新しいフォームのクライアント領域より大きくなっています。ユーザーがコントロールでスクロールを行えるように、 AutoScroll プロパティを true に設定して、フォーム上にスクロール バーを表示します。この例は、この例で定義されているメソッドが別のフォームからイベント ハンドラか他のメソッドで呼び出されることを前提にしています。
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
[C#]
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();
}
[C++]
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 = S"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();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ