Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

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

  • 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 224,741 Super User 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

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,663 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,741 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans