如何在gridcontrol中删除焦点所在的行
若以下回答无法解决问题,邀请你更新回答
1个回答
展开全部
//删除单条记录
private void btnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
DialogResult dialogResult = MessageBox.Show("是否删除该记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (dialogResult==DialogResult.OK)
{
string taskNum = gvTask.GetFocusedRowCellValue("任务编号").ToString();
string connectionString = "Integrated Security=False;User ID=sa;Password=2630989;Initial Catalog=RDSS3;Server=.";
SqlConnection con = new SqlConnection(connectionString);
string deleteString = "delete from dbo.ExpTask where TaskNum='" + taskNum + "'";
SqlCommand cmd = new SqlCommand(deleteString, con);
con.Open();
cmd.ExecuteNonQuery();
gvTask.DeleteRow(gvTask.FocusedRowHandle);
}
else
{
return;
}
}
private void btnDelete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
DialogResult dialogResult = MessageBox.Show("是否删除该记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
if (dialogResult==DialogResult.OK)
{
string taskNum = gvTask.GetFocusedRowCellValue("任务编号").ToString();
string connectionString = "Integrated Security=False;User ID=sa;Password=2630989;Initial Catalog=RDSS3;Server=.";
SqlConnection con = new SqlConnection(connectionString);
string deleteString = "delete from dbo.ExpTask where TaskNum='" + taskNum + "'";
SqlCommand cmd = new SqlCommand(deleteString, con);
con.Open();
cmd.ExecuteNonQuery();
gvTask.DeleteRow(gvTask.FocusedRowHandle);
}
else
{
return;
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询