急急急急~~~~~·我想选中datagridview第一列中的一行,并删除,怎么做
我想选中datagridview第一列中的一行,并删除,怎么做--------------------编程问答--------------------
--------------------编程问答--------------------
private void datagridview1_cellclick(object sender, DataGridViewCellEventArgs e)
{
index = e.RowIndex;
if (index < 0)
{
return;
}
string bookCode = this.dataGridView1.CurrentRow.Cells[2].Value.ToString();//获得ID值
if (e.ColumnIndex == 1)
{
DialogResult dr;
dr = MessageBox.Show("确定要删除吗?", "", MessageBoxButtons.OKCancel);
if (dr == DialogResult.Cancel)
{
return;
}
dc.deleteDataBook(bookCode);//删除的方法
DataTable dt = dc.getDataBook(getSql(), Convert.ToInt32(txtCurrentPage.Text.ToString()));//刷新数据
dataGridView1.DataSource = dt;
}
private void button2_Click(object sender, EventArgs e)
{
//选中DGV中的第一行
this.dataGridView1.Rows[0].Selected = true;
}
private void button3_Click(object sender, EventArgs e)
{
//从DGV中移除第一行
this.dataGridView1.Rows.Remove(this.dataGridView1.Rows[0]);
}
补充:.NET技术 , C#