我有 ToolStripButton1.Click,当我单击它时,会添加该行。我不希望这样的事情发生 请看这里的问题 谢谢
Public Class Form2
Dim myTable As New DataTable()
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles Me.Load
myTable.Columns.Add("Name")
DataGridView1.DataSource = myTable
DataGridView1.AllowUserToAddRows = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'No Problem
DataGridView1.AllowUserToAddRows = Not DataGridView1.AllowUserToAddRows
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
'But This Event Problem?
DataGridView1.AllowUserToAddRows = Not DataGridView1.AllowUserToAddRows
End Sub
End Class
我想使用 ToolStripButton1.Click 事件设置 AllowUserToAddRows 变量 true 或 false
我认为这可能是一个很好的解决方案
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) 处理 ToolStripButton1.Click '新解决方案 DataGridView1..CurrentCell = 无 DataGridView1.AllowUserToAddRows = 不是 DataGridView1.AllowUserToAddRows 结束子