//根据当前选中的单元格,根据当前行的情况设定当前选中的办事处的原有信息,此时修改按钮有效 private void DataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { DataGrid1.Select(DataGrid1.CurrentRowIndex); textBox_Office_ID.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString(); textBox_Office_Name.Text = conn.Office_IDtoWhat(textBox_Office_ID.Text, "Office_Name"); comboBox1_QuXian.SelectedValue = (int.Parse(conn.Office_IDtoWhat(textBox_Office_ID.Text, "QuXian_ID_OfficeIn"))); button1.Enabled = true; }
private void DataGrid1_CurrentCellChanged(object sender, System.EventArgs e) { DataGrid1.Select(DataGrid1.CurrentRowIndex); textBox_Committee_ID.Text = DataGrid1[DataGrid1.CurrentRowIndex, 0].ToString(); textBox_Committee_Name.Text = conn.Committee_IDtoWhat(textBox_Committee_ID.Text, "Committee_Name"); comboBox_QuXian.SelectedValue = (int.Parse(conn.Office_IDtoWhat(conn.Committee_IDtoWhat(textBox_Committee_ID.Text, "Office_ID"), "QuXian_ID_OfficeIn"))); //按数据库里边存储的办事处绑定下拉列表 string errorstring = conn.BindComboBox("Select * from Office Where QuXian_ID_OfficeIn=" + comboBox_QuXian.SelectedValue.ToString(), comboBox_Office, "Office_ID", "Office_Name"); if (errorstring != "OK") { MessageBox.Show("请检查数据库!" + errorstring, "提醒!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); button1.Enabled = false; return; } comboBox_Office.SelectedValue = (int.Parse(conn.Committee_IDtoWhat(textBox_Committee_ID.Text, "Office_ID"))); button1.Enabled = true; }