web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Dialog text size and button focus

(0) ShareShare
ReportReport
Posted on by 1,559

Hi Friends,

I just use Dialog class to create simple dialog, how can I set text size? also, the focus is on 'Ok' button,

how can I change it to 'Cancel' button?

Many thanks,

River

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    5400 Profile Picture
    7,162 on at

    Dialogtext    tx;

    FormButtonControl               OkButton ;

    dialog = new Dialog("My Dialog");

       tx = dialog.addText("Select your favorite customer:");

       tx.displayHeight(40); or whatever property u want to set

    OkButton = dialog.dialogForm().control(#OkButton);

    OkButton .setfocus();

    More info.

    https://community.dynamics.com/ax/b/daxbeginners/archive/2014/07/01/how-to-hide-or-disable-cancel-button-on-dialog

  • Ganriver1 Profile Picture
    1,559 on at

    Hi Bhaskar,

    Here is code  I put in, compiling is fine, but, I got run time error, saying setFocus() is not method of CancelButton.

    Error executing code: FormBuildCommandButtonControl object does not have method 'setFocus'

    Any hint?

           dialogText.displayHeight(40);

           CancelButton = dialog.dialogForm().control('cancelButton');

           CancelButton.setFocus();

    if I do:

    CancelButton = dialog.dialogForm().control(#cancelButton);

    then, I got macro #cancelButton not existed error.

  • Suggested answer
    Bashir Ahmad Profile Picture
    5,248 on at

    o set the focus on specific control when form is open, you need to override the firstField() method of the form and set your desired control after super() call.

    public void firstField(int _flags=1)

    {

          super(_flags);

       desiredControlName.setFocus();

    }

  • Ganriver1 Profile Picture
    1,559 on at

    Hi Bashir,

    You talk about 'form', mean the dialog form?

  • 5400 Profile Picture
    7,162 on at

    You have to declared first.

    If you are using macro you have to define the macro first in class declaration.

    [tag:define].cancelButton('cancelButton')

    FormButtonControl CancelButton;

    Please override the dialogPostRun method and write below code.

    public void dialogPostRun(DialogRunbase _dialog)
    {
        FormButtonControl myCtrl;
        super(_dialog);
    
        myCtrl = _dialog.dialogForm().formRun().control(CancelButton.id());
        myCtrl.setFocus();
     }
    

    Please check

  • Ganriver1 Profile Picture
    1,559 on at

    Hi Guys,

    I need to clarify what I want to do here.

    I have a dropdown box on Form, when value changed to a specific one, I need to pop up a dialog box with Ok and Cancel button, and I want focus on Cancel button.

    It's basic a warning message.

    Bhaskar, dialogPostRun method is for class, right?

  • Verified answer
    5400 Profile Picture
    7,162 on at

    it is very simple.  

    if (put your logc regarding data change  && Box::okCancel("write your message", DialogButton::Yes) == DialogButton::Yes)

       {

       }

  • Ganriver1 Profile Picture
    1,559 on at

    This is what I am looking for, thanks.

  • Ganriver1 Profile Picture
    1,559 on at

    One more question, after user click cancel button, I want dropdown box reset back to originial value, how should I do it?

    This dialog box, I pop it up in 'modified' method of dropdown, how can I find out old value, also, when I reset value back, surely, I don't want 'modified' method be called again.

  • AXDeveloperJunior Profile Picture
    100 on at

    How can we do it in new version? It is deprecated

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans