Overwrite OnChar
, count the number of new-lines in the text and then set ctrl.LimitText(500 - count)
. This way you avoid busting the DBs 500 char limit.
You also have to watch for paste events which could break the limit, as described here: How does a CRichEditCtrl know a paste operation has been performed?