选择除1st之外的任何行时索引超出范围错误

时间:2017-02-12 08:55:15

标签: indexing range out

当双击datagridview而不是1st的任何行时,我得到"索引超出范围错误"。双击第一行给出值。请帮忙

我的代码如下:

    Private Sub dgv_searchassistant_CellDoubleClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv_searchassistant.CellDoubleClick

    Dim rowindex As Integer = dgv_searchassistant.CurrentCell.RowIndex
    Dim columnindex As Integer = dgv_searchassistant.CurrentCell.ColumnIndex

    TextBox30.Text = dgv_searchassistant.Rows(rowindex).Cells(columnindex).Value
    TextBox27.Text = dgv_searchassistant.Rows(rowindex).Cells(2).Value

    dgv_searchassistant.Visible = False
    dgv_searchassistant.AutoGenerateColumns = False
    dgv_searchassistant.DataSource = Nothing

End Sub

0 个答案:

没有答案