author=BazzaCAD link=topic=1580.msg7727#msg7727 date=1296150081 wrote:
There isn't a property to limit the number of lines, but you could enable the "ReturnPressed" event & handle it there.
If the user presses return more then 4 times, then you could make the text box read-only or read the "text" value & truncate it if needed...
Based on your suggestion to truncate the text value of the box, I've come up with an enhancement to my code to prevent the user entering too many characters on the last line. My original code only took into account if the user hits to go to the next line. However my code wouldn't prevent the user from continuously typing while on the last line to the point where the text wraps down to the next line. Theoretically the user could just keep typing without hitting forever ;D
Hopefully with this little enhancement I've got everything covered. Thanks for your suggestion.
(defun c:1_form1_dwgtitle_OnEditChanged ( Newvalue / linecnt )
(setq linecnt (dcl_TextBox_GetLineCount 1_form1_dwgtitle))
(cond
((>= 3 linecnt)(dcl_Control_SetReturnAsTab 1_form1_dwgtitle nil))
((< 3 linecnt)(dcl_Control_SetReturnAsTab 1_form1_dwgtitle T))
)
(if (> linecnt 4)
(progn
(setq txt1 (dcl_TextBox_GetLine 1_form1_dwgtitle 0))
(setq txt2 (dcl_TextBox_GetLine 1_form1_dwgtitle 1))
(setq txt3 (dcl_TextBox_GetLine 1_form1_dwgtitle 2))
(setq txt4 (dcl_TextBox_GetLine 1_form1_dwgtitle 3))
(setq txtlst (strcat txt1 "\r\n" txt2 "\r\n" txt3 "\r\n" txt4))
(dcl_Control_SetText 1_form1_dwgtitle txtlst)
(dcl_Control_SetFocus 1_form1_custdwgnum)
)
)
(princ)
)