1

I am using TEdit in Delphi XE3, as it is a single line control. I don't expect it will allow text with new line character. However, today one of my customer send a file which contains the data from the edit box, which is:

'DN-60C4A18F-53A567CF-2E468912'#$D#$A'DN-60C4A18F-53A567CF-2E468912'

It contains a new line character #$D#$A. How can it be? And how to prevent this from occurring again?

Thanks

alancc
  • 487
  • 2
  • 24
  • 68
  • 1
    Yes, a TEdit can contain CR/LF pairs. It just doesn't break on them, because it's not a multi-line control. That can't be turned off - it's part of the built-in Windows edit control that TEdit wraps. – Ken White Jul 21 '21 at 01:36
  • 7
    `#$d` and `#$a` are just characters, too. And don't be too surprised if even a tabulator can occur in your `TEdit.Text`. **Any** character is allowed. How it got there? Easily thru pasting from the clipboard. Wanting to "prevent" this is the wrong approach - instead don't trust your user's input and validate it, then present out error messages. – AmigoJack Jul 21 '21 at 01:41

0 Answers0