DpRadioGroupBox 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package DpRadioGroupBox --version 1.0.2
NuGet\Install-Package DpRadioGroupBox -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DpRadioGroupBox" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DpRadioGroupBox --version 1.0.2
#r "nuget: DpRadioGroupBox, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DpRadioGroupBox as a Cake Addin
#addin nuget:?package=DpRadioGroupBox&version=1.0.2

// Install DpRadioGroupBox as a Cake Tool
#tool nuget:?package=DpRadioGroupBox&version=1.0.2

DpRadioGroupBox.md

Overview

DpRadioGroupBox is a simple extension of GroupBox, which adds a property SelectedTag. The idea is that the developer adds any number of RadioButtons to the DpRadioGroupBox and sets the Tag property of each to a unique integer string value and the SelectedTag to the integer tag value of the initially pressed button.

From there on, the SelectedTag property of the DpRadioGroupBox returns the integer Tag of the included 'RadioButton' that is checked.

If a RadioButton is clicked which does not have a valid tag (may be empty or contains a value that does not resolve to an integer), the button will be selected but no change will be made to SelectedTag. An InvalidDataException will be thrown, with a message that identifies the name of the offending `RadioButton1.

A utility method CheckIntegrity is provided to check that all RadioButtons in a DpRadioGroupBox have valid tags. It should be called immediately after InitializeComponent in the Form's constructor. However, it will not catch a problem where an invalid RadioButton is set as checked in the designer. This will cause the InvalidDataException to be thrown as InitializeComponent tries to set SelectedTag with an invalid value.

Package and Namespace

The package name is DpWinControls The namespace is DpWinForms.

Using the Control

  1. Ensure that the package is loaded into th Form project.
  2. Drag a copy of the DpRadioGroupBox on to the form's design surface and set the control's Text property as required.
  3. Drag as many RadioButtons as required on to the surface of the group box.
  4. For each RadioButton, set the Tag property of the button to a unique integer value and the Text property as appropriate.
  5. Optionally, bind the SelectedTag property of the DpRadioBox to an integer property of the BindingSource.

Constructor

public DpRadioGroupBox () : base () { }

Simply created by DpRadioGroupBox grpBox = new ();

Public Property

SelectedTag

public int SelectedTag { get; set; }

SelectedTag gets or sets the radio button on the control that is 'checked'. The integer value corresponds to the value in the Tag property of the RadioButton concerned. If an invalid (unknown as a Tag) integer value is supplied to a set operation, no change takes place.

Method

CheckIntegrity

public List<string> CheckIntegrity ()

Returns a list of the names of any RadioButtons within the DpRadioGroupBox which do not have valid Tag properties.

Event

SelectedTagChanged

public event EventHandler<SelectedTagEventArgs> SelectedTagChanged;

The parent control may subscribe to this event (on the DpRadioGroupBox), which fires when there is a change in the selected RadioButton. The selection state may be obtained by eg:

`MyRadioGroup.SelectedTagChanged += MyRadioGroupChanged;`
`...`
private void MyRadioGroupChanged (object sender, SelectedTagEventArgs e)
{ int newlySelectedButtonTag = e.SelectedTag; 	... }

SelectedTagEventArgs contains a single member int SelectedTag, which is the Tag value of the selected RadioButton.

Product Compatible and additional computed target framework versions.
.NET net7.0-windows7.0 is compatible.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0-windows7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on DpRadioGroupBox:

Package Downloads
DpChangeTracker

Enables the developer to track which controls are 'dirty'. Also provides the facilities to return all controls to their initial state (cancel changes) and to make the current state of controls the 'clean' state (eg after file save).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.1 72 5/11/2024
1.1.0 64 5/11/2024
1.0.2 245 10/31/2023
1.0.1 89 10/31/2023
1.0.0 96 10/30/2023

Initial Release