Databinding Radio Buttons in a Winforms Group Box
-
I sort of have databinding working with a set of Radio buttons in a winforms group box. I have implemented a class with that extends INotifyPropertyChanged with seperate properties for each radio button (Demo below). On my form I have grouped the radio buttons into a group box so that only one button can be selected at a time. Then under DataBindings I have used the advanced option to set the "checked" value and the data source update mode to "OnPropertyChanged". The problem that I am having is that each change in selection requires the user to click twice on the destination radio button to make a selection. using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; namespace PizzaOrder { class OrderData : INotifyPropertyChanged { public OrderData() { m_largePizza = true; } #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } #endregion private bool m_smallPizza = false; public bool SmallPizza { get { return m_smallPizza; } set { if (m_smallPizza != value) { m_smallPizza = value; OnPropertyChanged("SmallPizza"); } } } private bool m_mediumPizza = false; public bool MediumPizza { get { return m_mediumPizza; } set { if (m_mediumPizza != value) { m_mediumPizza = value; OnPropertyChanged("MediumPizza"); } } } private bool m_largePizza = false; public bool LargePizza { get { return m_largePizza; } set { if (m_largePizza != value) { m_largePizza = value; OnPropertyChanged("LargePizza"); } } } } }