Personal tools
From wiki.swiftlytilting.com
Jump to: navigation, search

WinBinder Manual/RadioButton

A RadioButton is a control used for making a choice. It is typically used in groups so the user may select one from several options. To create a radio button use the wb_create_control() function using RadioButton as the class parameter.

Contents

Using radio buttons

  • Radio buttons are designed to work in groups. You may use a radio button alone, but this is not considered standard practice.
  • Only one radio button from within a given group can be checked each time.
  • The radio button that starts each group must include WBC_GROUP in the style argument of <winterpostwiki>wb_create_control</winterpostwiki>.
  • It is not necessary to create a Frame to group radio buttons, except for cosmetics.
  • Radio buttons that are stored on different tab pages are always grouped separately.
  • To create a radio button that is already checked, set the param argument of <winterpostwiki>wb_create_control</winterpostwiki> to 1.

Creating radio buttons

// Create two radio button groups

// Group A

wb_create_control($mainwin, Frame,       "Group A",   10,  6, 85, 89);                    // For cosmetics only
wb_create_control($mainwin, RadioButton, "Option A1", 20, 24, 70, 14, 101, WBC_GROUP, 0); // Group start
wb_create_control($mainwin, RadioButton, "Option A2", 20, 48, 70, 14, 102, 0,         1); // Checked
wb_create_control($mainwin, RadioButton, "Option A3", 20, 73, 70, 14, 103  0,         0);

// Group B

wb_create_control($mainwin, Frame,       "Group B",   110,  6, 85, 89);                    // For cosmetics only
wb_create_control($mainwin, RadioButton, "Option B1", 120, 24, 70, 14, 201, WBC_GROUP, 1); // Group start, checked
wb_create_control($mainwin, RadioButton, "Option B2", 120, 48, 70, 14, 202, 0,         0);
wb_create_control($mainwin, RadioButton, "Option B3", 120, 73, 70, 14, 203, 0,         0);

Retrieving the selected state of a radio button

To retrieve currently selected state of a radio button, call <winterpostwiki>wb_get_selected</winterpostwiki>() or <winterpostwiki>wb_get_value</winterpostwiki>().

See also

Winbinder Projects