> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/flatredball-forms/controls/radiobutton.md).

# RadioButton

### Introduction

The RadioButton control can be used to select from a number of options. RadioButton instances are grouped according to their parent and a group name. Only one RadioButton in a parent/group combination can be selected at once. Selecting another RadioButton in the same group will deselect other RadioButton instances.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-539ffa4c544d5891f8a300a4a61cea96faf55715%2F2017-12-2017-12-21_07-04-05.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Layout Requirements

The RadioButton control has no requirements – an empty container is sufficient. [![](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-7df5b1d9ecb4e17429e8da801a66e003bd401a3c%2F2017-12-img_5a485e78076db.png?alt=media)](https://github.com/flatredball/FlatRedBallDocs/tree/main/media/2017-12-img_5a485e78076db.png)

### TextInstance

The RadioButton control can optionally include a Text instance named **TextInstance**. Setting the RadioButton control’s **Text** property changes the **TextInstance’s** displayed string.

### Groups and Parents

The default Group for RadioButton instances is an empty string. Therefore, all grouping is done by parent. This is sufficient for most cases as groups of radio buttons may need to be visually separated from one another, and this is often done by assigning different parents in Gum.

<figure><img src="https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-4b6a940a8873e6b1e47321eda8959ec6288c8539%2F2017-12-2017-12-21_07-27-46.gif?alt=media" alt=""><figcaption></figcaption></figure>

### Handling Events

The RadioButton class provides events for whenever it is checked, unchecked, or clicked (similar to the CheckBox class). The Checked and Unchecked events can be handled to respond to the specific state changing, as shown in the following code example:

```lang:c#
void CustomInitialize()
{
    var radioButton = TutorialScreenGum
        .GetGraphicalUiElementByName("RadioButtonInstance")
        .FormsControlAsObject as RadioButton;

    radioButton.Checked += HandleRadioButtonChecked;
    radioButton.Unchecked += HandleRadioButtonUnchecked;
}

private void HandleRadioButtonChecked(object sender, EventArgs e)
{
    // Perform checked-related logic
}

private void HandleRadioButtonUnchecked(object sender, EventArgs e)
{
    // Perform unchecked-related logic
}
```

RadioButton also exposes the more general Click event which can be used to handle any click regardless of IsChecked state, as shown in the following example:

```lang:c#
void CustomInitialize()
{
    var radioButton = TutorialScreenGum
        .GetGraphicalUiElementByName("RadioButtonInstance")
        .FormsControlAsObject as RadioButton;
 
    radioButton.Click += HanleRadioButtonClick;
}
 
private void HanleRadioButtonClick(object sender, EventArgs e)
{
    // Perform click-related logic
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/api/flatredball-forms/controls/radiobutton.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
