日期:2014-05-18 浏览次数:20918 次
private void dgvVar_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (this.dgvVar.CurrentCell != null && this.dgvVar.CurrentCell.OwningColumn.Name == "colVarType") { ComboBox cb = e.Control as ComboBox; cb.SelectedIndexChanged += new EventHandler(FormIntelligenceDocument_SelectedIndexChanged); } } void FormIntelligenceDocument_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cb = sender as ComboBox; if (cb != null) { if (cb.Text == "其它字典") this.dgvVar.CurrentRow.Cells["colVarZD"].Value = this._VarTypeZD.Rows[0]["Code"]; else this.dgvVar.CurrentRow.Cells["colVarZD"].Value = null; ////让变量类型失去焦点 //this.dgvVar.EndEdit(); //(sender as ComboBox).SelectedIndexChanged -= new EventHandler(FormIntelligenceDocument_SelectedIndexChanged); } }
private void dgvVar_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { cb.SelectedIndexChanged -= new EventHandler(FormIntelligenceDocument_SelectedIndexChanged); if (this.dgvVar.CurrentCell != null && this.dgvVar.CurrentCell.OwningColumn.Name == "colVarType") { ComboBox cb = e.Control as ComboBox; cb.SelectedIndexChanged += new EventHandler(FormIntelligenceDocument_SelectedIndexChanged); } }
------解决方案--------------------