[VB.NET]怎么删除Dataset里的被Datagrid指定的行

前端之家收集整理的这篇文章主要介绍了[VB.NET]怎么删除Dataset里的被Datagrid指定的行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
怎么删除Dataset里的被Datagrid指定的行 Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object,ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick If e.Button Is bhExit Then Me.Close() End If If e.Button Is bhAdd Then Dim newForm As New useradd newForm.Show() End If If e.Button Is bhDel Then DataGrid1.Select(DataGrid1.CurrentRowIndex) If (MessageBox.Show( 您确定要删除这一行吗?,提示,MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.Yes) Then ???????? End If End If End Sub __________________________________________________________________________ 怎么没人帮忙...... __________________________________________________________________________ 郁闷 __________________________________________________________________________ 取到选中行数据的主键或唯一标志,操作数据库即可 __________________________________________________________________________ 你的一行数据至少有一个字段或者多个字段的组合能标识这行是唯一的吧。 然后用这种组合去DataSet里查找,然后删除这一行,然后再重新绑定DataGrid __________________________________________________________________________ 我只能想象,能给段代码么??? __________________________________________________________________________ tCust.Rows(dgResult.CurrentCell.RowNumber).Delete() 得到行号 __________________________________________________________________________ Dim bm As BindingManagerBase Private Sub Form10_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load dapsw.Fill(DataSet21) DataGrid1.SetDataBinding(DataSet21,psw ) bm = Me.BindingContext(DataSet21,psw ) End Sub Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click Dim dgrDelete = DialogResult Try dgrDelete = MessageBox.Show( 是否要删除记录?,MessageBoxButtons.YesNo) If dgrDelete = DialogResult.Yes Then With bm .RemoveAt(.Position) End With MessageBox.Show( 删除成功,提示 ) dapsw.Update(DataSet21) DataSet21.AcceptChanges() End If Catch err As Exception MessageBox.Show(err.Message) End Try End sub 我的给你参考下 __________________________________________________________________________ 原文链接:https://www.f2er.com/vb/263679.html

猜你在找的VB相关文章