ComboBox DataSets Qty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My Program: a local C# ADO.Net application using VS 2003

Right now I have about 5 ComboBox's which provides drop down selection
entries from the same MS-Access table via a DataConnection, DataAdapter and
DataSet datasource. Each CB has it's own DA and DS. When I tried to use the
same DS as the datadource for each of the five CB's, changing one of the CB's
selection affectd the other four CB's.

New business requirements require I increase the number of CB's from 5 to
about 100. What do I do? Do I create 100 DA and DS?

Steve
 
Hi,
inline

Steve B. said:
My Program: a local C# ADO.Net application using VS 2003

Right now I have about 5 ComboBox's which provides drop down selection
entries from the same MS-Access table via a DataConnection, DataAdapter
and
DataSet datasource. Each CB has it's own DA and DS. When I tried to use
the
same DS as the datadource for each of the five CB's, changing one of the
CB's
selection affectd the other four CB's.

Instead of using a different DataSource (DataSet) for each ComboBox, you can
use a different BindingContext :

comboBox1.BindingContext = new BindingContext();
comboBox1.DataSource = ds; // same datasource
comboBox1.DisplayMember = ....;

comboBox2 .BindingContext = new BindingContext();
comboBox2.DataSource = ds; // same datasource
comboBox2.DisplayMember = ....;

.....

This way the comboboxes will create different CurrencyManagers(which
mantains position) for the same datasource/datamember and allow independent
navigating.


HTH,
greetings
 
Bart

Thank You for responding. Great Idea. Will try it this weekend.

One question, the DataSource and DisplayMember assignments are in VS CB
properties window. Where do I put the comboBox1.BindingContext = new
BindingContext() statement so I get it in the order you specified or can I
put it anywhere (i.e. Constuctor, form Load() event)? Can I somehow get "new
BindingContext()" into the VS CB (DataBinding) block ?? Or do I remove the
CB DataSource and DisplayMemeber and put it all in my code after the
InitializeComponent();

Steve
 
Hi,

Steve B. said:
Bart

Thank You for responding. Great Idea. Will try it this weekend.

One question, the DataSource and DisplayMember assignments are in VS CB
properties window. Where do I put the comboBox1.BindingContext = new
BindingContext() statement so I get it in the order you specified or can I
put it anywhere (i.e. Constuctor, form Load() event)? Can I somehow get
"new
BindingContext()" into the VS CB (DataBinding) block ?? Or do I remove
the
CB DataSource and DisplayMemeber and put it all in my code after the
InitializeComponent();

It doesn't matter where you bind, from code or with the properties window.
The new BindingContext assignments can only be done in in code. A good
place would be after InitializeComponent() in the constructor.

If you want independent navigating, sorting and filtering, you can:
Create a different dataview for each combox and bind that ( from code or
designer ) .

If you only want independent navigating you can gain some performance:
Create a single dataview (designer or code) and bind that to all ComboBoxes
and then give each ComboBox a new BindingContext from code.


HTH,
greetings
 
Bart,

Again thank you for the free input

Yes, I do want sorting of the comboBox dropdown but didn't know how to do it
Not real familar dataview but have used it once or twice - need to check it
out.
 
Bart

Hope your still there, It gets a little more differcult.

The db may already have a entry for that field that should be loaded as
ComboBox.text when the form opens. The user should also have a choice to
edit the field without changing the other 20 "charaCode" fields

From IntializeComponent() method:
this.charaCode1CB.DataBindings.Add(new System.Windows.Forms.Binding("Text",
this.csiDbDS, "Main.CharacteristicCodes1"));

Adding "charaCode1CB.BindingContext = new BindingContext();" seems to
remove that previous binding

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top