private void dgd_delete_DoubleClick(object sender, System.EventArgs e)
{
int x = this.dgd_modfiy.CurrentCell.RowNumber;
int y = this.dgd_modfiy.CurrentCell.ColumnNumber;
string strsel = "delete * from Info_Collect where Collect_ID = '"+dgd_modfiy[x,y].ToString()+"'";
DialogResult MsgBoxResult;//设置对话框的返回值 MsgBoxResult = MessageBox.Show("确认要删除吗?",//对话框的显示内容 "提示",//对话框的标题 MessageBoxButtons.YesNo,//定义对话框的按钮,这里定义了YSE和NO两个按钮 MessageBoxIcon.Exclamation,//定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号 MessageBoxDefaultButton.Button2);//定义对话框的按钮式样 if (MsgBoxResult == DialogResult.Yes)//如果对话框的返回值是YES(按"Y"按钮) {
DbManagerSQL.ExecuteSql(strsel); }
}
{
int x = this.dgd_modfiy.CurrentCell.RowNumber;
int y = this.dgd_modfiy.CurrentCell.ColumnNumber;
string strsel = "delete * from Info_Collect where Collect_ID = '"+dgd_modfiy[x,y].ToString()+"'";
DialogResult MsgBoxResult;//设置对话框的返回值 MsgBoxResult = MessageBox.Show("确认要删除吗?",//对话框的显示内容 "提示",//对话框的标题 MessageBoxButtons.YesNo,//定义对话框的按钮,这里定义了YSE和NO两个按钮 MessageBoxIcon.Exclamation,//定义对话框内的图表式样,这里是一个黄色三角型内加一个感叹号 MessageBoxDefaultButton.Button2);//定义对话框的按钮式样 if (MsgBoxResult == DialogResult.Yes)//如果对话框的返回值是YES(按"Y"按钮) {
DbManagerSQL.ExecuteSql(strsel); }
}
解决方案 »
- OpenFileDialog的时候内存怎么释放??
- 这里有懂PYTHON的吗?我有个PYTHON的代码想转换为C#的代码没多少
- Devxpress GridControl 修改 出现 band 和 column 挂不在一起,求助有没有解决方法?
- excel 导出数据时怎么避免过长数据显示为科学计数法
- 带个问题散分
- 有没有关于winform比较好的书
- 用过InstallShield X Express高手们,来指点一下呀!万分感谢!
- 请问这个 List<string> 类型怎么分别控制升序和降序
- 求个代码,关于多字符串查找匹配替换的问题
- 高分求DeKlarit的使用说明和教程!
- 保存图片出错 大家看看是什么原因
- 在线播放视频的问题
private void DataGrid1_DeleteCommand(object source, DataGridCommandEventArgs e)
{
SqlConnection cn;
SqlCommand cmd;
string strDelete; cn = new SqlConnection( connectionString);
strDelete = "delete from Note Where id = @id";
cmd = new SqlCommand(strDelete, cn );
cmd.Parameters.Add("@id", SqlDbType.VarChar).Value = DataGridView.DataKeys[(int)e.Item.ItemIndex].ToString();
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
DataGrid1.EditItemIndex = -1;
BindDataGrid();//重新绑定
}