vb.net – 以编程方式更改DatagridView(.NET)上的选择

我在学VB.NET

尝试设置CurrentCell的值时,DataGridView组件有问题.
我想要做的是:

我有一个DataGridView与值.
我想在我的表单中创建一个按钮,当点击它时,我想将选择从当前行更改为下一个.要解释更多,点击我的按钮我想模拟鼠标点击DataGridview的效果.

我希望你能帮助我,

谢谢!

也许这样的事情:
If DataGridView1.RowCount > 0 Then

        Dim MyDesiredindex As Integer = 0

        If DataGridView1.CurrentRow.Index < DataGridView1.RowCount - 1 Then
            MyDesiredindex = DataGridView1.CurrentRow.Index + 1
        End If

        DataGridView1.ClearSelection()            
        DataGridView1.CurrentCell = DataGridView1.Rows(MyDesiredindex).Cells(0)
        DataGridView1.Rows(MyDesiredindex).Selected = True

    End If

注1:也许这两行不是必需的.我没有证明

DataGridView1.ClearSelection()            
        DataGridView1.CurrentCell = DataGridView1.Rows(MyDesiredindex).Cells(0)

注2:请注意,如果我们在最后一行,它将首先进行

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...