Bonnie,
I had to make some slight "corrections" to the code you posted in the DataBind method. Code below shows the changes I had to make. Could you please review the changes and let me know what you think?
The line "this.DataBindings.Clear();" I removed because I think it might be useless (well for me anyways).
I had to clear the databindings for each control inside the usercontrol individually because the DataBind() method will be called several times with different instances of the Class1 class.
Einar
public void DataBind(object BindTo)
{
if (BindTo is Class1)
{
this.numericUpDown1.DataBindings.Clear();
this.numericUpDown2.DataBindings.Clear();
this.checkBox1.DataBindings.Clear();
Class1 o = (Class1)BindTo;
this.numericUpDown1.DataBindings.Add("Value", o, "N1");
this.numericUpDown2.DataBindings.Add("Value", o, "N2");
this.checkBox1.DataBindings.Add("Checked", o, "C1");
}
}
>Sure Einar, no problem ... I just *had* to do it ... databinding is one of my specialties and it bothers me when people don't do it right. <g>
>
>~~Bonnie
>
>
>
>>Bonnie,
>>Thank you very much for the sugestions (it sure beat my "fix" of rewriting a lot of my pretty usercontrols). Thank you very much for taking the time to run and look at my code.
>>
>>Sincerely,
>>Einar
>>
>>>Yes, I ran your code and it certainly behaved the way you described it ... and it's because of the way you've done your properties, having their get/set manipulate the .Value of the control. That's not really how you should databind controls.
>><snip>
Semper ubi sub ubi.