datagridview怎样在选中行点“DEL”键删除时,出现确认提示!
程序允许DataGridView控件删除行,但是点击键盘上的Del键删除时?怎么出现提示?
我的msbox语句应该放到哪里?
[解决办法]
- VB.NET code
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown MsgBox("确定要删除么?",MsgBoxStyle.YesNo) End Sub
[解决办法]
- VB.NET code
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown If e.KeyValue = 46 Then MsgBox("确定要删除么", MsgBoxStyle.YesNo) End If End Sub
[解决办法]
- VB.NET code
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown If e.KeyValue = 46 andalso not DataGridView1.coloumn(e.coloumnindex).name.equals("NO")Then MsgBox("确定要删除么", MsgBoxStyle.YesNo) End If End Sub
[解决办法]
Dim intRowTemp As Integer = 0 '当前DataGridView的行
Private Sub DataGridView1_CellMouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.CellMouseUp
If e.Button = System.Windows.Forms.MouseButtons.Right Then
intRowTemp = e.RowIndex
End If
End Sub
Private Sub DataGridView1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles DataGridView1.KeyDown
If e.KeyValue = 46 andalso not DataGridView1.rows(intRowTemp).name.equals("NO")Then 可能不正有境有法 你自己一下
MsgBox("确定要删除么", MsgBoxStyle.YesNo)
End If
End Sub