TextBox.Multiline Proprietà
Definizione
public:
virtual property bool Multiline { bool get(); void set(bool value); };
public override bool Multiline { get; set; }
member this.Multiline : bool with get, set
Public Overrides Property Multiline As Boolean
Valore della proprietà
true
se il controllo è un controllo TextBox su più righe; in caso contrario, false
.true
if the control is a multiline TextBox control; otherwise, false
. Il valore predefinito è false
.The default is false
.
Esempio
Nell'esempio di codice seguente viene creato un TextBox controllo su più righe con barre di scorrimento verticali.The following code example creates a multiline TextBox control with vertical scroll bars. In questo esempio vengono utilizzate le AcceptsTab AcceptsReturn proprietà, e WordWrap per rendere il controllo casella di testo su più righe utile per la creazione di documenti di testo.This example uses the AcceptsTab, AcceptsReturn, and WordWrap properties to make the multiline text box control useful for creating text documents.
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 to be entered 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!";
}
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 to be entered 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!";
}
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 to be entered 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!"
End Sub
Commenti
AutoCompleteSource non funziona sui controlli su più righe TextBox .AutoCompleteSource does not work on multiline TextBox controls.
Quando il tipo di carattere viene modificato, non viene visualizzato alcun rientro definito.When the font is changed, any indentation that you have defined does not appear. Per ottenere il rientro, impostare Multiline su true
ed eseguire l'override WM_SETFONT senza chiamare la classe di base in modo che i margini non vengano chiamati.To get indentation, set Multiline to true
and override WM_SETFONT without calling the base class so that SETMARGINS is not called.