Hellow everyone,
in the below screen i need to set focus on barcode Number once open the form and once add value to it set focus on Quantity filed and also once click enter to add new line and focus on Barcode Number
Hi Gunjan,
i solved the problem by the following code:
1- to set focus on the field once the form opened i copy Activited event in form data source and add this code
[FormDataSourceEventHandler(formDataSourceStr(SalesTable, SalesLine), FormDataSourceEventType::Activated)]
public static void SalesLine_OnActivated(FormDataSource sender, FormDataSourceEventArgs e)
{
FormRun fr = sender.formRun() as FormRun;
fr.design().controlName(formControlStr(SalesTable,SalesLine_modItemBarCode)).setFocus();
}
2- to set focus on Quantity filed and copy the Modified event for the control and add this code
[FormControlEventHandler(formControlStr(SalesTable, SalesLine_modItemBarCode), FormControlEventType::Modified)]
public static void SalesLine_modItemBarCode_OnModified(FormControl sender, FormControlEventArgs e)
{
FormRun fr = sender.formRun() as FormRun;
fr.design().controlName(FormControlstr(SalesTable,SalesLine_SalesQty)).setFocus();
}
Can You try this code to access the form control from the control name?
public FormControl findFormControl(FormControlName _name) { int controlId = formRun.controlId(_name); FormControl control = formRun.control(controlId); return control; }
The auto declaration property for the control is NO an i can't change it
Hi Ahmed,
Have you tried controlName.setFocus()? For setting focus on the quantity field you can use the same statement in the modified method of the Bar code field.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156