Forum Discussion

RobertDAltman's avatar
RobertDAltman
Occasional Contributor
7 years ago

How to access UserForm radio button Caption

I have a UserForm that I display from JavaScript

 

var userForm = UserForms.StartupForm;
var formResult = userForm.ShowModal();

The UserForm contains a RadioGroup with several radio buttons on it.  How do I fetch the Caption property of the selected radio button?

  • Many thanks to Evgeny in tech support for this solution:

     

    // In this example, a form named MyForm contains a radio button group
    // named radioGroup.

    // Display a modal form var frm = UserForms.MyForm; var modalResult = frm.ShowModal(); // Get the selected radio button var idx = frm.radioGroup.ItemIndex; var rb = frm.radioGroup.ChildControl(idx); // Access properties on the radio button control var selectedCaption = rb.Caption;

    Note that code completion doesn't display any properties or methods for the radio button object.

  • YuriPeshekhonov's avatar
    YuriPeshekhonov
    SmartBear Alumni (Retired)

    Hi,

     

    The "ItemIndex"property returns the selected item index:

     

    var index = UserForms.UserForm1.cxRadioGroup1.ItemIndex

  • RobertDAltman's avatar
    RobertDAltman
    Occasional Contributor

    Many thanks to Evgeny in tech support for this solution:

     

    // In this example, a form named MyForm contains a radio button group
    // named radioGroup.

    // Display a modal form var frm = UserForms.MyForm; var modalResult = frm.ShowModal(); // Get the selected radio button var idx = frm.radioGroup.ItemIndex; var rb = frm.radioGroup.ChildControl(idx); // Access properties on the radio button control var selectedCaption = rb.Caption;

    Note that code completion doesn't display any properties or methods for the radio button object.