法一:如果已经连接数据源、表、有查询语句,单击右键,选择“字段刷新”(retrieve fields),确定。
法二:单击右键,选择“编辑”(edit)编辑该控件,通过编辑控件(此时再次单击右键,插入行或列)完成
vb.net Datagridview添加行,需要四个按钮,一个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条)