On my form information about a group is displayed as:
1. Group Name:__________ (i/p control: textBox)
2. Is Primary: O No O Yes (i/p control: radioButtons)
I want to data bind the checked property of the two radio buttons above, with my object.
The object is as:
public class DTOItemGroup
{
public short id { get; set; }
public string name { get; set; }
public Nullable<short> idParent { get; set; }
}
Back in the code, I tried binding it as:
BindingSource bs;
void InitializeThis(StockTools stockTools)
{
bs = new BindingSource();
bs.DataSource = typeof(DTOItemGroup);
form_StockTools.tb_GroupName.DataBindings.Add("Text", bs, "name");
form_StockTools.rb_IsPrimaryNo.DataBindings.Add("Checked", bs, "idParent", true, DataSourceUpdateMode.OnPropertyChanged, false);
form_StockTools.rb_IsPrimaryYes.DataBindings.Add("Checked", bs, "idParent", true, DataSourceUpdateMode.OnPropertyChanged, true);
}
Binding for the textbox is working fine. But, for radio buttons, binding is not working at all. Whenever I change the object attached to binding source (bs), the radio buttons doesn't get checked.
I am very new to binding. Please guide me on how to data bind a group of radio buttons.
What I have tried:
I googled for radio button checked property data binding tutorial over google but had no help. I know this must be an easy task, but I can't really figure out it.