I need to place the cursor to the end of the text in a text field. when user open a dialog box, the field will contain some default value. I need to place the cursor to the end of text in the field, so that user can enter the text directly with out moving the cursor to the end of the text. can any one help me regarding this. i need to do this in axapta 2009.
int lastIndex = strLen(StringEdit1.text());
StringEdit1.setFocus();
StringEdit1.setSelection(lastIndex,lastIndex);
When testing a simple example, I found a bit strange behavior when the text contained line breaks. It seems to me that if you add \n to your text, it’s counted as a single character, but it’s replaced by \r\n in the form control and setSelection() counts that as two characters. If you use \r\n (or #delimiterCRLF from #File macro) in your text, it works as expected.
You can’t set cursor position when only defining how the form should look like, you have to do it when the form is constructed (FormStringControl, unlike FormBuildStringControl, is capable of setting cursor position). (That you don’t get an error when assigning FormBuildStringControl object to FormStringControl variable is caused by a limitation of the runtime type control; it’s not a valid assignment).
Create a dialog form (use tutorial_RunbaseForm as an example) and do all necessary form handling there.