Hello!
I am currently designing a UserControl with a Memoedit in it, I am using the input in the memoedit in a narrow text area and want to restrict users from entering more than two lines worth of input!
Is there a simple way to limit the amount of lines in a memoedit, or do I need to manually create a mask or something, to restrict the user from entering more than two lines of input?
Best Regards
-Dan
Limited number of lines in MemoEdit
Answers approved by DevExpress Support
Hello Dan,
Unfortunately, there is no property to limit the number of lines in a memo edit control, and masks are not supported for these controls. Consider handling the control's EditValueChanging event to prevent new line characters from being inserted. See the example below:
C#private void memoEdit1_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) {
string s = e.NewValue as string;
int index1 = s.IndexOf("\r\n");
if(index1 >= 0 && s.IndexOf("\r\n", index1 + 2) >= 0)
e.Cancel = true;
}
Visual BasicPrivate Sub memoEdit1_EditValueChanging(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ChangingEventArgs)
Dim s As String = TryCast(e.NewValue, String)
Dim index1 As Integer = s.IndexOf(Constants.vbCrLf)
If index1 >= 0 AndAlso s.IndexOf(Constants.vbCrLf, index1 + 2) >= 0 Then
e.Cancel = True
End If
End Sub
Thank you, Alex.