Ticket Q21297
Visible to All Users

Limited number of lines in MemoEdit

created 18 years ago

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

Answers approved by DevExpress Support

created 18 years ago (modified 8 years ago)

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 Basic
Private 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.

    Comments (1)
    DevExpress Support Team 18 years ago

      Ok. Thank you for the feedback. I've closed this issue.
      Best regards, Alex.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.