Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

How to get the value of an unbound combo box control

Posted on by 690

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

  • JoeBrewer Profile Picture
    JoeBrewer 690 on at
    RE: How to get the value of an unbound combo box control

    Thanks Martin. Much appreciated.

    Joe

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,214 Most Valuable Professional on at
    RE: How to get the value of an unbound combo box control

    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
    JoeBrewer 690 on at
    RE: How to get the value of an unbound combo box control

    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

  • Chaitanya Golla Profile Picture
    Chaitanya Golla 17,225 on at
    RE: How to get the value of an unbound combo box control

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans