如何在DataGridView中的ComboBox列的下一行中添加不同的数据 [英] How to add different Data in Next Row of ComboBox Column in DataGridView
本文介绍了如何在DataGridView中的ComboBox列的下一行中添加不同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 DataGridView
ComboBox
列中添加一些值,但是
例如 - 第一行数据将在 ComboBox
栏中 abcd 栏目
2nd行中的数据将是 abcdefg 在 ComboBox
列
表示我想要不同行中的不同项目在同一 ComboBox
列。
I want to add some values in DataGridView
ComboBox
column, but
for example- 1st row the data will "abcd" in ComboBox
Column
2nd row the data will be "abcdefg" in ComboBox
Column
means I want different items in different rows on same ComboBox
Column.
推荐答案
如何添加第一行然后更新项目在ComboBoxColumn中
how about add first the row then update the items in the ComboBoxColumn
Dim dtgCol As DataGridViewComboBoxCell
Dim row As String()
row = New String() {"0", "1"}
dtgView.Rows.Add(row)
dtgCol = dtgView.Rows(0).Cells(2)
dtgCol.Items.Add("comboitem1")
dtgCol.Items.Add("comboitem2")
row = New String() {"2", "3"}
dtgView.Rows.Add(row)
dtgCol = dtgView.Rows(0).Cells(2)
dtgCol.Items.Add("comboitem1")
dtgCol.Items.Add("comboitem2")
dtgCol.Items.Add("comboitem3")
这只是我的想法..我已经完成了...希望这有帮助
this is just my idea.. I already done this... hope this helps
只需在每一行中添加新的组合框单元格
Simply add new comboBox Cell in every row
DataGridViewComboBoxCell dgvCmbCell;
dgvCmbCell = (DataGridViewComboBoxCell)myGrid.Rows[rowInx].Cells[colInx];
dgvCmbCell.Items.Clear();
dgvCmbCell.Value = null;
//And make your loop
while (...)
{
dgvCmbCell.Items.Add(.....);
}
我相信它会达到您的要求;
I believe it will reach your requirement;
这篇关于如何在DataGridView中的ComboBox列的下一行中添加不同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文