Need to place the cursor to the end of text when the dialog box is opened.

hai all,

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.

thanks and regards


Check this out:

int lastIndex = strLen(StringEdit1.text());

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.

Dear Martin Dráb,

thanks for the replay. but still i am facing some issue with this. I am adding the code which I am using.

DialogRunBase dialog = super();

FormStringControl fsc;


dialog.caption("@SYS106947"); // Approval Description

dNotes = dialog.addFieldValue(TypeId(Notes),notes, “@SYS70989”);

fsc = dNotes.control(;




return dialog;

this is the cod which I am using. but it shows some run time error.

the error Message is follows,

"Error in executing the code : FormBuildStringControl object does not have method "setFocus"

I also tried with the method "setCursorPos()"

Thanks and Regards


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.