Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am trying to give a groupbox its own currency manager. The problem is that when I create a new bindingContext and assign it to a groupbox, the bound textboxes fail to show any data (they do display data if I keep the form's binding context).

Why would the textboxes not display data at all when their container control is assigned a new bindingContext?

I think the currencymanager is being created for each groupbox, but the textbox no longer seem to be bound.
C#
private void BindControls()
{
   BindingContext bcG1 = new BindingContext();
   BindingContext bcG2 = new BindingContext();
   groupBox1.BindingContext = bcG1;
   groupBox2.BindingContext = bcG2;
   textBox1.DataBindings.Add("Text", ds, "Customers.CustName");
   textBox2.DataBindings.Add("Text", ds, "Customers.CustName");
}
private void Button1_Click(object sender, EventArgs e)
{
   groupBox1.BindingContext[ds, "Customers"].Position += 1;         
}
private void Button2_Click(object sender, EventArgs e)
{
   groupBox2.BindingContext[ds, "Customers"].Position += 1;
}


Thanks
Posted
Updated 26-Oct-10 4:43am
v2

1 solution

Why do you want to maintain separate currencymanager for both groupboxes?Do you have other controls on form sharing same datasource?If each GroupBox control has its own CurrencyManager object for the Customers data source,changing position property of one doesnt change the other.

There is a workaround mentioned here in VB.Net . Convert it to C# & apply

Page 148 of this pdf

http://www.bluevisionsoftware.com/WebSite/Books/0972317929/Ch06.pdf[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900