更新 : 2007 年 11 月
このコントロールが複数行テキスト ボックス コントロールかどうかを示す値を取得または設定します。
名前空間 :
System.Windows.Forms アセンブリ :
System.Windows.Forms (System.Windows.Forms.dll 内)
Public Overridable Property Multiline As Boolean
Dim instance As TextBoxBase
Dim value As Boolean
value = instance.Multiline
instance.Multiline = value
public virtual bool Multiline { get; set; }
public:
virtual property bool Multiline {
bool get ();
void set (bool value);
}
/** @property */
public boolean get_Multiline()
/** @property */
public void set_Multiline(boolean value)
public function get Multiline () : boolean
public function set Multiline (value : boolean)
プロパティ値
型 :
System..::.Boolean
コントロールが複数行テキスト ボックス コントロールである場合は true。それ以外の場合は false。既定値は false です。
複数行テキスト ボックスでは、コントロールに複数行のテキストを表示できます。WordWrap プロパティが true に設定されている場合、複数行テキスト ボックスに入力されたテキストは、コントロール内の次の行に折り返されます。WordWrap プロパティが false に設定されている場合、複数行テキスト ボックス コントロールに入力されたテキストは、改行が行われるまで同じ行に表示されます。
改行文字として使用できる定数を次に示します。
ScrollBars プロパティを使用すると、テキスト ボックスにスクロール バーを追加したり、水平スクロール バーまたは垂直スクロール バー (あるいはその両方) を表示したりできます。ユーザーはスクロール バーを使用してコントロールに収まらないテキストをスクロールできます。
メモ : |
|---|
日本語のオペレーティング システムでは、Multiline プロパティを true に設定すると、PasswordChar プロパティを設定した場合にパスワードのテキストが表示されるため、システム セキュリティが低下します。このため、日本語のオペレーティング システムで PasswordChar プロパティを設定する場合は、Multiline プロパティを false に設定します。 |
メモ : |
|---|
このプロパティは、RichTextBox コントロール以外のすべての派生クラスで、既定で false に設定されています。 |
RichTextBox コントロールでは、RichTextBox..::.Multiline プロパティによって、コントロールが自動的にサイズ変更されるかどうかが次のように決定されます。
派生クラス TextBox を使用して、垂直スクロール バーのある複数行 TextBox コントロールを作成するコード例を次に示します。この例では、AcceptsTab、AcceptsReturn、WordWrap の各プロパティも使用して、テキスト ドキュメントを作成しやすいように複数行テキスト ボックス コントロールを設定します。
Public Sub CreateMyMultilineTextBox()
' Create an instance of a TextBox control.
Dim textBox1 As New TextBox()
' Set the Multiline property to true.
textBox1.Multiline = True
' Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical
' Allow the RETURN key in the TextBox control.
textBox1.AcceptsReturn = True
' Allow the TAB key to be entered in the TextBox control.
textBox1.AcceptsTab = True
' Set WordWrap to true to allow text to wrap to the next line.
textBox1.WordWrap = True
' Set the default text of the control.
textBox1.Text = "Welcome!" & Environment.NewLine & "Second Line"
End Sub
public void CreateMyMultilineTextBox()
{
// Create an instance of a TextBox control.
TextBox textBox1 = new TextBox();
// Set the Multiline property to true.
textBox1.Multiline = true;
// Add vertical scroll bars to the TextBox control.
textBox1.ScrollBars = ScrollBars.Vertical;
// Allow the RETURN key in the TextBox control.
textBox1.AcceptsReturn = true;
// Allow the TAB key to be entered in the TextBox control.
textBox1.AcceptsTab = true;
// Set WordWrap to true to allow text to wrap to the next line.
textBox1.WordWrap = true;
// Set the default text of the control.
textBox1.Text = "Welcome!" + Environment.NewLine + "Second Line";
}
public:
void CreateMyMultilineTextBox()
{
// Create an instance of a TextBox control.
TextBox^ textBox1 = gcnew TextBox;
// Set the Multiline property to true.
textBox1->Multiline = true;
// Add vertical scroll bars to the TextBox control.
textBox1->ScrollBars = ScrollBars::Vertical;
// Allow the RETURN key in the TextBox control.
textBox1->AcceptsReturn = true;
// Allow the TAB key to be entered in the TextBox control.
textBox1->AcceptsTab = true;
// Set WordWrap to true to allow text to wrap to the next line.
textBox1->WordWrap = true;
// Set the default text of the control.
textBox1->Text = "Welcome!" + Environment::NewLine + "Second Line";
}
public void CreateMyMultilineTextBox()
{
// Create an instance of a TextBox control.
TextBox textBox1 = new TextBox();
// Set the Multiline property to true.
textBox1.set_Multiline(true);
// Add vertical scroll bars to the TextBox control.
textBox1.set_ScrollBars(ScrollBars.Vertical);
// Allow the RETURN key in the TextBox control.
textBox1.set_AcceptsReturn(true);
// Allow the TAB key to be entered in the TextBox control.
textBox1.set_AcceptsTab(true);
// Set WordWrap to true to allow text to wrap to the next line.
textBox1.set_WordWrap(true);
// Set the default text of the control.
textBox1.set_Text("Welcome!" + Environment.get_NewLine()
+ "Second Line");
} //CreateMyMultilineTextBox
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
.NET Framework および .NET Compact Framework では、各プラットフォームのすべてのバージョンはサポートしていません。サポートされているバージョンについては、「.NET Framework システム要件」を参照してください。
.NET Framework
サポート対象 : 3.5、3.0、2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 3.5、2.0、1.0
参照