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)

How to get the value of an unbound combo box control

(0) ShareShare
ReportReport
Posted on by 692

Hi

I have extended a form and added an unbound combo box which has a new base enum as its enum type. How do I get the value of the combo box in the OnModified event handler? The sender variable which is of type FormControl doesn't seem to have a selection() method. Do I need to cast this to another type?

Thanks,
Joe

*This post is locked for comments

I have the same question (0)
  • Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Could you please elaborate your requirement(or if I am missing something), as I don't think we cannot add eventhandler to the form control modified method.

    Thanks,

    Chaitanya Golla

  • JoeBrewer Profile Picture
    692 on at

    Hi

    Here is the code I am using - the event handler has been copied from the combo box object on the form.

    [FormControlEventHandler(formControlStr(TransportationDocument, MyComboBox), FormControlEventType::Modified)]
        public void MyComboBox_OnModified(FormControl sender, FormControlEventArgs e) { }


    I just need to know what value has been selected when a user changes the value.

    Thanks,
    Joe

  • Verified answer
    Martin Dráb Profile Picture
    237,817 Most Valuable Professional on at

    You must realize that the event handler has the same signature for all types of controls, therefore sender is declared as something compatible with all controls (= their common parent class). But the value of you get has a concrete type, such as FormComboBoxControl, and you can cast sender to it to be able to access its methods.

    FormComboBoxControl combobox = sender as FormComboBoxControl;
    if (combobox)
    {
        ...
    }
  • JoeBrewer Profile Picture
    692 on at

    Thanks Martin. Much appreciated.

    Joe

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans