开发者

Grid View Combo Box Column

I am working on a Windows Form.

I have a ComboBox and on it's SelectedIndexChanged, I need to bind va开发者_运维知识库lues 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜