Hi all!

Im using a ComboBox and a DataGridView in a Form and use the same DataSet-Table for both. Unfortunately they automatically synchronice their current selection now. When I select a row in the grid for editing, the ComboBox gets automatically switched. How can I avoid this absolutely unwanted behaviour? I allready checked all Properties and couldnt find anything.

Greetings!
Zorgoban

Recommended Answers

All 4 Replies

use two dataset instances one for each of which.

Thanks, but no. Im not a fan of unclean coding. I still dont know what caused the problem, but when I dont use the designer to set the datasource, but instead do it myselfe in the code, it works like expected:

// init language dropdown datasource
// when it is set via designer, it synchronices selection with new languagestring datagrid
// absolute bullcrap
m_LanguageCombo.DisplayMember = "lngName";
m_LanguageCombo.ValueMember = "lngId";
m_LanguageCombo.DataSource = m_DataSource.Tables["language"];

This sounds like the normal behaviour of a bound dataset. When multiple controls use the same bindingsource (Navigators, Grid, Combo, Listbox, etc), any component that causes the bindingsource.Position to change effects all components bound to the same bindingsource.

Either use two bindingsources (one for the grid and its navigator), the other for the combobox, or like Ramy said, use a different table in the dataset. Its not unclean code either way, its just a mater of using the correct binding.

I personally refrain from using the data designer for reasons like this. I build my own Data Access Layer (DAL) class that does the same thing, but with the finite control I desire.

// Jerry

Sorry I was mean use two "bindingsources" not "dataset" and this not bad solution it's the only solution

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.