把 datagridview的ContexMenuStrip属性项绑定为你所添加的ContexMenuStrip1控件,然后就是你自己编写程序来 *** 作删除具体的东西了
您好,要实现非常简单。需要四个按钮,一个datagridview控件。代码如下
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'添加行
Me.DataGridView1.Rows.Add()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'添加列
Me.DataGridView1.Columns.Add("1", "on")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'删除行
Me.DataGridView1.Rows.RemoveAt(0)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'删除列
Me.DataGridView1.Columns.RemoveAt(0)
End Sub
End Class
以上如有不清楚,您可以继续追问。希望对您有用!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)