private void btnDelete_Click(object sender, EventArgs e) { if (!CheckSelectedRow()) { return; } if (MessageDialog.ShowEnquiryMessage("您是否要删除选择行?") == DialogResult.No) { return; } // 获取到修改行索引 int rowIndex = dataGridView1.CurrentRow.Index; int id = (int)dataGridView1.CurrentRow.Cells[0].Value; if (!m_storeServer.DeleteStore(id, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } QueryStock(); RefreshControl(); string strColName = ""; foreach (DataGridViewColumn col in dataGridView1.Columns) { if (col.Visible) { strColName = col.Name; break; } } // 自动跳到下一行记录 if (dataGridView1.Rows.Count > 0) { dataGridView1.FirstDisplayedScrollingRowIndex = rowIndex; dataGridView1.CurrentCell = dataGridView1.Rows[rowIndex].Cells[strColName]; } chk_PT.Enabled = false; }