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.


9 Years
Discussion Span
Last Post by Ramy Mahrous

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.