DpRadioGroupBox 1.0.2
See the version list below for details.
dotnet add package DpRadioGroupBox --version 1.0.2
NuGet\Install-Package DpRadioGroupBox -Version 1.0.2
<PackageReference Include="DpRadioGroupBox" Version="1.0.2" />
paket add DpRadioGroupBox --version 1.0.2
#r "nuget: DpRadioGroupBox, 1.0.2"
// 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
- Ensure that the package is loaded into th Form project.
- Drag a copy of the
DpRadioGroupBox
on to the form's design surface and set the control'sText
property as required. - Drag as many
RadioButtons
as required on to the surface of the group box. - For each
RadioButton
, set theTag
property of the button to a unique integer value and theText
property as appropriate. - Optionally, bind the
SelectedTag
property of theDpRadioBox
to an integer property of theBindingSource
.
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 | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0-windows7.0 is compatible. net8.0-windows was computed. |
-
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.
Initial Release