TextBox.Multiline Propriedade
Definição
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
Valor da propriedade
true
se o controle for um controle TextBox multilinha; caso contrário, false
.true
if the control is a multiline TextBox control; otherwise, false
. O padrão é false
.The default is false
.
Exemplos
O exemplo de código a seguir cria um controle de várias linhas TextBox com barras de rolagem vertical.The following code example creates a multiline TextBox control with vertical scroll bars. Este exemplo usa as AcceptsTab AcceptsReturn Propriedades, e WordWrap para tornar o controle de caixa de texto de várias linhas útil para a criação de documentos de texto.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
Comentários
AutoCompleteSource Não funciona em controles de várias linhas TextBox .AutoCompleteSource does not work on multiline TextBox controls.
Quando a fonte for alterada, qualquer recuo definido não será exibido.When the font is changed, any indentation that you have defined does not appear. Para obter recuo, defina Multiline para true
e substitua WM_SETFONT sem chamar a classe base para que SetMargins não seja chamado.To get indentation, set Multiline to true
and override WM_SETFONT without calling the base class so that SETMARGINS is not called.