Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. Databinding Radio Buttons in a Winforms Group Box

Databinding Radio Buttons in a Winforms Group Box

Scheduled Pinned Locked Moved Windows Forms
csharpwinformshelpannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fredsparkle
    wrote on last edited by
    #1

    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"); } } } } }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups