Hi,
never done that before.. sorry. Just an idea (may be a little hackish):
Derive a control from RadioButton. Add a new property
"Unchecked" which inversely wraps the "Checked" property:
public bool Unchecked
{
get{return !Checked;}
set{Checked = !value;}
}
and bind
radioButton1.DataBindings.Add("Checked", test, "Male");
inverseRadioButton1.DataBindings.Add("Unchecked", test, "Male");
If you find a more elegant way let me know
akim
On Wed, 9 Feb 2005 19:50:39 -0500, Hemang Shah <(E-Mail Removed)> wrote:
> What if I have only one boolean datafield in the database say "gender"
> Mostly when you give the options of radio button only one value can be
> selected at anytime, and thus only 1 value to be stored in the database.
---------------------
>> bind any boolean property to the "Checked" property of the
>> radiobuttons; See example below;
>> private void Form1_Load(object sender, System.EventArgs e)
>> {
>> Test test = new Test(false);
>> radioButton1.DataBindings.Add("Checked", test, "Male");
>> radioButton2.DataBindings.Add("Checked", test, "Female");
>> }
>>
>> public class Test
>> {
>> bool male;
>> public Test(bool male)
>> {
>> this.male = male;
>> }
>> public bool Male
>> {
>> get{return male;}
>> }
>> public bool Female
>> {
>> get{return !male;}
>> }
>> }
---------------
>>> I cannot seem to figure out what property do you bind the data to in a
>>> radiobutton ?
>>> So if I have a boolean value in the dataset "Gender" how do I set it
>>> using 1 group and 2 radiobuttons ?