ScrollableControl.AutoScrollMargin プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ScrollableControl Dim value As Size value = instance.AutoScrollMargin instance.AutoScrollMargin = value
[LocalizableAttribute(true)] public: property Size AutoScrollMargin { Size get (); void set (Size value); }
/** @property */ public Size get_AutoScrollMargin () /** @property */ public void set_AutoScrollMargin (Size value)
自動スクロールのマージンの高さと幅をピクセル単位で表す Size。


自動スクロールのマージンは、子コントロールからスクロール可能な親コントロールの端までの距離です。AutoScrollMargin サイズは、スクロール バーが必要かどうかを判断するスクロール可能なコントロールに格納された、すべての子コントロールのサイズに追加されます。AutoScrollMargin プロパティは、スクロール可能な親コントロールがサイズ変更されるか、または個別の子コントロールがビューに表示されたときに評価され、スクロール バーを表示する必要の有無を判断するために使用されます。ドッキングされたコントロールは、スクロール バーを表示する必要の有無を判断する計算から除外されます。
![]() |
---|
ドッキングされたコントロールの Dock プロパティが DockStyle.Fill に設定されている場合は、コントロールにスクロール可能な親コントロールが表示され、スクロール バーが必要かどうかを判断する AutoScrollMargin を使用した場合は、ドッキングされたコントロールは無視されます。 |
子コントロールの端からスクロール可能な親コントロールまでの距離が AutoScrollMargin プロパティに割り当てられた値未満であり、AutoScroll プロパティが true に設定されている場合、該当するスクロール バーが表示されます。

派生クラス Panel を使用するコード例を次に示します。この例では、テキスト ボックスの位置を評価し、その親コンテナであるパネル コントロールの外観と動作を変更します。この例では、Panel コントロール、TextBox、および Button のインスタンスが作成されている必要があります。テキスト ボックスをパネルに配置する場合は、少なくとも 1 つのパネルの端と重なるようにします。ボタンがクリックされたときにこの関数を呼び出して、パネルの動作と外観の違いを確認します。
Private Sub SetAutoScrollMargins() ' 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
private void SetAutoScrollMargins() { /* 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); } } }
void SetAutoScrollMargins() { /* 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 SetAutoScrollMargins() { /* If the text box is outside the panel's bounds, turn on auto-scrolling and set the margin. */ if (text1.get_Location().get_X() > panel1.get_Location().get_X() || text1.get_Location().get_Y() > panel1.get_Location().get_Y()) { panel1.set_AutoScroll(true); /* If the AutoScrollMargin is set to less than (5,5), set it to 5,5. */ if (panel1.get_AutoScrollMargin().get_Width() < 5 || panel1.get_AutoScrollMargin().get_Height() < 5) { panel1.SetAutoScrollMargin(5, 5); } } } //SetAutoScrollMargins

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からScrollableControl.AutoScrollMargin プロパティを検索する場合は、下記のリンクをクリックしてください。

- ScrollableControl.AutoScrollMargin プロパティのページへのリンク