Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

How to hide Control on Radio button Click

Posted on by 1,010

Hello All,

I have added one control Radio Button in form with data type Enum. This enum contains two Elements:  Working days (enum value 1) and Calender Days ( enum value 2). On the radio button Click (enum 1) i want to hide group control and for enum value 2, I want to show group. for that i have override selectionchange( ) method and written following code.

public int selectionChange()
{
int ret;
if(radiobutton.selection(1))
{
DaysGroup.visible(false);
radiobutton.selection(2);
}
else if (radiobutton.selection(2))
{
DaysGroup.visible(true);
radiobutton.selection(1);
}
ret = super();

return ret;

}

Now, I am debugging and whenever i am changing radio button values from 1 to 2, the cursor is always going on only if(radiobutton.selection(1)) loop.

The same code i have written in Modified (override method) method of Radio button but still it is same.

 

  • Anton Venter Profile Picture
    Anton Venter 9,930 Super User on at
    RE: How to hide Control on Radio button Click

    You're welcome :)

  • D.K.S. Profile Picture
    D.K.S. 1,010 on at
    RE: How to hide Control on Radio button Click

    Thanks Anton,.

  • Suggested answer
    5400 Profile Picture
    5400 7,160 on at
    RE: How to hide Control on Radio button Click

    Please find the good practice to write this type of code

    Example:

    please write a one method as below in form method node and call it in required place.

    public void enabledControl()

    {

       if (RadioButton.selection() == NoYes::Yes)

       {

           Group1.visible(true);

       }

       else

       {

           Group1.visible(false);

       }

    }

    please call it init method() first for default or you can set default visable value in control.

    after that same method you can call in selectionChange() method.

    Thanks

    Bhaskar

  • Verified answer
    Anton Venter Profile Picture
    Anton Venter 9,930 Super User on at
    RE: How to hide Control on Radio button Click

    Hi, your code should be something like this:

    public int selectionChange()
    {
        int ret;
    
        if (radiobutton.selection() == 1) //put your enum value here instead of 1
        {
            DaysGroup.visible(false);
        }
        else if (radiobutton.selection() == 2) //and here instead of 2
        {
            DaysGroup.visible(true);
        }
    
        ret = super();
    
        return ret;
    }

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans