Skip to main content

RadioGroup Class

Combines multiple options (radio buttons) into a group that supports selecting one of several options.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v23.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public class RadioGroup :
    BaseEdit,
    IPagerControl

The following members return RadioGroup objects:

Remarks

The RadioGroup editor allows an end user to select one of multiple options. Selecting an item deselects the one previously selected, so only one item can be selected at a time.

RadioGroupClass

A user can switch between group buttons by clicking the required button with the mouse or by pressing the arrow keys. The Page Up and Page Down keys set the first and last items, respectively.

Radio buttons in the control are RadioGroupItem object instances. To create a radio group control, create a RadioGroup object and add RadioGroupItem items to the RepositoryItemRadioGroup.Items collection (accessible through the control’s RadioGroup.Properties property).

Use the RepositoryItemRadioGroup.ItemsLayout property to specify how items are arranged. Two item arrangement modes are supported:

  • Column (Default)

    radioGroup-ColumnLayout

  • Flow

    radioGroup-FlowLayout

On screen, radio buttons are identified by specific display captions. Use the RadioGroupItem.Description property to set an item’s caption. Each radio button must be associated with a specific value via the RadioGroupItem.Value property. On selecting an item, its value is automatically assigned to the control’s value specified by the BaseEdit.EditValue property.

Radio group item display captions cannot be localized in the same way as standard RadioButton controls. See the How to make internal strings in my application localizable KB article to learn more.

To get the selected item, use the RadioGroup.SelectedIndex property. This property gets or sets the selected item’s index in the RepositoryItemRadioGroup.Items collection. To change the selected item programmatically, you can use the RadioGroup.SelectedIndex property or set the editor’s BaseEdit.EditValue property.

CheckEdit controls can also be used to display a group of radio buttons. See the RepositoryItemCheckEdit.RadioGroupIndex topic to learn more.

Pager Navigation

The RadioGroup and WindowsUIButtonPanel can be used as a pager for the following controls:

PagerNavigation.gif

The pager automatically splits the target control’s content into pages, and displays navigation buttons to scroll to corresponding pages. The pager navigation functionality is implemented as a Behavior and can be added to your controls using the BehaviorManager component.

Tooltips

DevExpress controls support regular and super tooltips. If the ShowToolTips option is enabled, tooltips are shown when the mouse pointer hovers over the control.

Use the following properties to specify a regular tooltip’s content:

  • ToolTip — A regular tooltip’s text. If the text is not specified, the tooltip is not displayed even if the title is specified. You can use line breaks in regular tooltips. Use the AllowHtmlTextInToolTip property to specify whether to parse HTML tags in the text. HTML tags allow you to format the text: size, style, hyperlinks, etc.
  • ToolTipTitle — A regular tooltip’s title. If the title is not specified, it is not displayed.
  • ToolTipIconType — A regular tooltip’s predefined icon. Use the controller’s IconSize property to specify the image size.

    image

    To display a custom image in all regular tooltips, use the controller’s ImageList and ImageIndex properties.

    To display a custom image in a specific regular tooltip, handle the BeforeShow event. Use the ImageOptions event argument to assign a raster or vector image to the processed tooltip.

Use the SuperTip property to assign a super tooltip to a control. Enable the AllowHtmlText property to use HTML tags in the super tooltip.

To replace regular tooltips with super tooltips, set the ToolTipController.ToolTipType property to SuperTip. The controller automatically converts regular tooltips to super tooltips. To access this property, you can use the DefaultToolTipController component or a custom controller assigned to the ToolTipController property. See the following topic for more information: Hints and Tooltips.

Example

The following code shows how to add items to a RadioGroup and then select one of the items. To select an item, the item’s value is assigned to the editor’s BaseEdit.EditValue property.

RadioGroupClass

using DevExpress.XtraEditors.Controls;

// Create five items.
object[] itemValues = new object[] {10, 11, 12, 13, 14};
string [] itemDescriptions = new string [] {"Circle", "Rectangle", "Ellipse", "Triangle", "Square"};
for(int i = 0; i < itemValues.Length; i++) {
    radioGroup1.Properties.Items.Add(new RadioGroupItem(itemValues[i], itemDescriptions[i]));
}
//Select the Rectangle item.
radioGroup1.EditValue = 11;

Inheritance

See Also