다음을 통해 공유


Form.AutoScroll 속성

폼에서 자동 스크롤 기능을 사용할 수 있는지 여부를 나타내는 값을 가져오거나 설정합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
<LocalizableAttribute(True)> _
Public Overrides Property AutoScroll As Boolean
‘사용 방법
Dim instance As Form
Dim value As Boolean

value = instance.AutoScroll

instance.AutoScroll = value
[LocalizableAttribute(true)] 
public override bool AutoScroll { get; set; }
[LocalizableAttribute(true)] 
public:
virtual property bool AutoScroll {
    bool get () override;
    void set (bool value) override;
}
/** @property */
public boolean get_AutoScroll ()

/** @property */
public void set_AutoScroll (boolean value)
public override function get AutoScroll () : boolean

public override function set AutoScroll (value : boolean)

속성 값

폼에서 자동 스크롤 기능을 사용하는 경우 true이고, 그렇지 않으면 false입니다. 기본값은 false입니다.

설명

이 속성이 true로 설정된 경우 컨트롤이 폼의 클라이언트 영역 밖에 있으면 해당 폼에 스크롤 막대가 표시됩니다. 또한 자동 스크롤 기능을 사용하면 입력 포커스가 있는 컨트롤이 표시되도록 폼의 클라이언트 영역이 자동으로 스크롤됩니다.

또한 이 속성을 사용하면 저해상도의 비디오 설정에서도 컨트롤을 볼 수 있습니다.

예제

다음 코드 예제에서는 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
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:
   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.set_Text("Scrolled Button");

    // Set the size of the button.
    button1.set_Size(new Size(100, 30));

    // Set the location of the button to be outside the form's client area.
    button1.set_Location(new Point(form2.get_Size().get_Width() + 200, 
        form2.get_Size().get_Height() + 200));

    // Add the button control to the new form.
    form2.get_Controls().Add(button1);

    // Set the AutoScroll property to true to provide scrollbars.
    form2.set_AutoScroll(true);

    // Display the new form as a dialog box.
    form2.ShowDialog();       
} //DisplayMyScrollableForm  

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0에서 지원

참고 항목

참조

Form 클래스
Form 멤버
System.Windows.Forms 네임스페이스