Multiline text block. Maximum allowed lines

I assume that there is a limitation for the lines selected in the TextBox, with the MultiLine parameter set to true.

I have a program that checks my email account every few minutes, but for management purposes, I put a TextBox that indicates what I did.

My curiosity: does anyone know how many lines are allowed? And is there an exception when reaching this line?

EDIT Sorry to forget to mention in WinForms

EDIT 2 Perhaps someone knows a way to eliminate old lines would be grateful

+5
source share
5 answers

, .

, . . .

+6

TextBox.MaxLength , .

+1

:

<TextBox x:Name="txtAddress" 
MaxLines="6"
TextWrapping="Wrap"  AcceptsReturn="True"
VerticalScrollBarVisibility="Hidden" 
HorizontalScrollBarVisibility="Hidden"
TextChanged="txtAddress_TextChanged"
PreviewTextInput="txtAddress_PreviewTextInput"
PreviewKeyDown="txtAddress_PreviewTextInput"/>

//...

private void txtAddress_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox txtBx = sender as TextBox;
if (txtBx.LineCount > txtBx.MaxLines)
txtAddress.Text = this._textBeforInput;
}

private string _textBeforInput = string.Empty;
private void txtAddress_PreviewTextInput(object sender, EventArgs e)
{
this._textBeforInput = txtAddress.Text;
}
+1

Multiline TextBox WinForms, ASP.NET. ( WPF:))

0

, , , HTML/ASP.NET, jsFiddle http://jsfiddle.net/Z3rdZ/2/

HTML

<textarea id="limited-lines" maxlines="4"></textarea>

JQuery

$('#limited-lines').keydown(function(event){
    if ( event.which == 13 ) {
        var numberOfLines = $(this).val().split('\n').length;
        if(numberOfLines >= $(this).attr('maxlines')){
            event.preventDefault();   
        }
    }
});
0

All Articles