Reputation: 297
I am working on a Windows Form.
I have a ComboBox and on it's SelectedIndexChanged, I need to bind values to a GridViewComboBox Column.
Suppose I have bound all the states in the ComboBox, then when a state is selected, I need to bind all the districts coming under the particular state.
How can I do it?
Upvotes: 0
Views: 584
Reputation: 11707
I am not sure of the question truly. Somewhere you wrote Combobox and sometimes GridViewComboBox. Still if you want what I am thinking:
datagridview dg;
string[] district = { "dis1", "dis2", "dis3" };
for (int i = 0; i < dg.Rows.Count; i++)
{
DataGridViewComboBoxCell cc = (DataGridViewComboBoxCell)dg["dgc", i];
cc.DataSource = country;
cc.Value = country[0];
}
dgc = Column name of DatagridViewComboboxColumn.
Here, putting the following code in State Combobox TextChanged event. String array district are district source. Tweak this concept according to your need, I think you will get what you are looking for. Need any more clarity, add a comment. Hope it helps.
Upvotes: 0