tags:

views:

85

answers:

1

Hi, all

I have a table in access database file. I would like to show that table in DataGridView, i have a bindingsource which bind to the table. then DataGridView bind to bindingsource. I also have other controls(textboxs, comboboxs) which are bind to 'dataMember' of table through the same bindingsource. Everything work well. But when i changed 'DropDownStyle' of the combobox from 'DropDown' to 'DropDownList'. The binding is broken. The data in the combobox is not changed when i selected different row in the datagridview. However, when i changed the data in combobox, the data in the cell in DataGridView changed. Anyone has idea? Thank you very much!

The following is my code: 

combobox1.Items.AddRange( new Object[]{
"Monday",
"Tuesday",
.....
.....
"Sunday"
});


bindingsource1.DataSource = dt; // dt is a instance of DataTable
combobox1.DataBindings.Add("Text", bindingsource1,"Day");
A: 
combobox1.DataBindings.Add("SelectedValue", bindingsource1,"Day");

[EDIT]

Add this:

comboBox1.DisplayMember = "Day";
Michael Buen
Thanks for your reply, but it is not working for my case