• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 542
  • Last Modified:

c# (winform) binding the same data to two fields?

hi all,

i have a function (below) and use of function below
i have two panels that show or hide depending on what data needs to be displayed

on both panels I need to bind address1 to two fields

i then get an error when debugging
System.ArgumentException: This causes two bindings in the collection to bind to the same property.

so im guessing i cant databind the same field to two different fields?
if not then how would you guys suggest i go about making this work?

Thanks for your help

databind(txtAddress1, "Text", dataSetClients.Clients, "Address1");
databind(txtWPAddress1, "Text", dataSetClients.Clients, "Address1");

// function to add a databind
private void databind(Control ctrlfieldName, string strType, object objTable, string strField)
{
    ctrlfieldName.DataBindings.Add(strType, objTable, strField, true, DataSourceUpdateMode.OnPropertyChanged);
}

Open in new window

0
awilderbeast
Asked:
awilderbeast
1 Solution
 
Ivo StoykovCommented:
try to clear binding first

HTH

Ivo Stoykov
ctrlfieldName.DataBindings.Clear();
ctrlfieldName.DataBindings.Add(strType, objTable, strField, true, DataSourceUpdateMode.OnPropertyChanged);

Open in new window

0
 
awilderbeastAuthor Commented:
thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now