datagridview1中ComboBox数据源更新
datagridview1中有两列
DataGridViewTextBoxColumn dgvTextCol_tuhao = new DataGridViewTextBoxColumn();
dgvTextCol_tuhao.Name = "col_tuhao";
dgvTextCol_tuhao.DataPropertyName = "tuhao";
dgvTextCol_tuhao.HeaderText = "图号";
dataGridView1.Columns.Add(dgvTextCol_tuhao);
DataGridViewComboBoxColumn dgvTextCol_pmgg = new DataGridViewComboBoxColumn();
dgvTextCol_pmgg.DataPropertyName = "partid";
dgvTextCol_pmgg.HeaderText = "品名规格";
dgvTextCol_pmgg.Name = "Col_pmgg";
dgvTextCol_pmgg.DisplayMember = "partname";
dgvTextCol_pmgg.ValueMember = "partid";
dgvTextCol_pmgg.DataSource = myOper.GetParts();
dataGridView1.Columns.Add(dgvTextCol_pmgg);
我希望实现一个功能是当textbox列内容变化时,更新ComboBox列的数据源。
textbox列内容变化的方法我已经会写了,现在就是不知道如何重新指定ComboBox列的数据源。
------解决方案--------------------找到控件后,重新绑定不行么?
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
IList<Info> infos = new List<Info>();
infos.Add(new Info("1", "1", "guwei4037"));
infos.Add(new Info("2", "2", "ladygaga"));
DataGridViewComboBoxCell combobox = this.dataGridView1.Rows[e.RowIndex].Cells["Col_pmgg"] as DataGridViewComboBoxCell;