Let's say we have a couple of RadioButton
objects (all: not selected) and we select one of them.
So what I want to know is; how to determine whether we had a RadioButton
selected or not. How can I acheive this in c#?
Let's say we have a couple of RadioButton
objects (all: not selected) and we select one of them.
So what I want to know is; how to determine whether we had a RadioButton
selected or not. How can I acheive this in c#?
See if any radio button is checked as follows;
var checkedButton = container.Controls.OfType<RadioButton>().FirstOrDefault(r => r.Checked);
If checkedButton
remains null then that means you have never selected any of these radio buttons.
In wpf, try following;
var checkedButton = container.Children.OfType<RadioButton>().FirstOrDefault(r => (bool)r.IsChecked);
Refer this for more description.