Is there a way to catch maximum length PER LINE and not allow user to input more characters if max length PER LINE has been reached?

后端 未结 4 1989
攒了一身酷
攒了一身酷 2020-12-22 04:06

Good day!

Sorry if I cant make it into code but here\'s my problem:

Im coding C#, using TextBox Control, Multiline = true.

Now, my problem is i need

4条回答
  •  情深已故
    2020-12-22 04:23

    textBox.OnTextChanged += (EventArgs e) => // invoked on every text change
    {
        var lines = myTextBox.Where(x.Length > 5); // Get the long lines
        for (var i; i < lines.Count(); i++)  // iterate over long lines
        {
            lines[i] = lines[i].Substring(0, 5); // replace the line with its substring(stripped) value
        }
    }
    

提交回复
热议问题