Accessing Radio Button in C#.NET - InfoPath Dev
in

InfoPath Dev

Accessing Radio Button in C#.NET

Last post 02-06-2007 11:00 PM by Shilpa Pitta. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-04-2007 09:51 PM

    • PakiDev
    • Not Ranked
    • Joined on 12-28-2006
    • Pakistan
    • Posts 10

    Accessing Radio Button in C#.NET

    Dear Gurus
    I have a infopath 2003 form with managed code in C#.Net, VS 2003, in which I have included a group of radio button namely personel and offcial.I want to show a textbox when personal is selected and hide the textbox if the official radio button is selected. My problem is how can I access these radio button programmetically in my C#.NET code, to make changes upon their selection mode.
    I am extremely helpless.

    Any help is welcome
    Regards
    Nasir
    Pakistan
  • 02-06-2007 02:59 AM In reply to

    Re: Accessing Radio Button in C#.NET

    Hi Nasir,
    Without using code also we can do this by applying conditional formatting on the section keeping text box in the section.

    Hope this helps you!
    Shilpa
    INFOPATHDEV India
  • 02-06-2007 05:14 AM In reply to

    Re: Accessing Radio Button in C#.NET

    Hi Paki,

    the easiest really is using conditional formatting. Double click the control you want to hide/show and select contditional formating.
    The select form the first dorpdownlist your radioButtonControl, in the second is not equal to and in the third "1" or "2" or Yes/No depending how you have set up your radion button.

    If you want to use code you can get a reference to your radion button control like this:
    IXMLDOMNode myRadioButton = thisXDocument.Dom.SelectSingleNode("my:myFields/my:RadioButtonControlName");

    and then use

    if(myRadioButton.text == "depending on how you have set the values to your radio button)
    Listen to Motörhead cos they play Rock'n Roll :)
  • 02-06-2007 08:21 PM In reply to

    • PakiDev
    • Not Ranked
    • Joined on 12-28-2006
    • Pakistan
    • Posts 10

    Re: Accessing Radio Button in C#.NET

    Wow... it is pretty simple and really worked... I have no words to thanks both of you... you are life savers...!
  • 02-06-2007 08:39 PM In reply to

    • PakiDev
    • Not Ranked
    • Joined on 12-28-2006
    • Pakistan
    • Posts 10

    Re: Accessing Radio Button in C#.NET

    Is there any way to hide or show a control programmatically specially in C#.NET
  • 02-06-2007 11:00 PM In reply to

    Re: Accessing Radio Button in C#.NET

    Hi Nasir,
    Here is the block of the code that you need in C#
    public bool showText()
    {
    int selected = Convert.ToInt16(thisXDocument.DOM.selectSingleNode("/my:myFields/my:Field1").text);
    if(selected == 0)
    {
    return true;
    }
    return false;
    }

    xdExtension:showText()

    Hope this helps you!
    Shilpa
    INFOPATHDEV India
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.