Click here to Skip to main content
15,906,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an app that lists warranty issues in a datagrid view. Users then double click anywhere within the row to open a new form with the details of the issue. My development machine is windows 7, VS 2015. It works on this machine fine. A colleague has a windows 10 laptop - it works fine on there. I have a windows 10 surface tablet - and here's the isolated case. I get the index has no value error when I double click on the datagrid view. The odd thing is, it's not on every row -that this happens. Code below of the click event. The commented section is the alternate method I've tried, both fail on the surface but work on the debug machine and other windows 10 machines. So it's been very difficult to find as I can't generate a call stack since I don't get the error debugging. All I am trying to do is find out what row the user clicked on, find a value in column 2 (column 1 is a hidden index) ... then open the detail form and filter the datasource to the column value which happens to be an incident number. I pass it via the value via variable "v" I have exhausted my search on this - as it works on most machines. but we have several people at my work that use surfaces - and it fails on surfaces. no idea why. any suggestions?

What I have tried:

VB
Public Sub dgvIssues_CellMouseDoubleClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvIssues.CellMouseDoubleClick

        If dgvIssues.Rows.Count > 0 Then
            Try
                If e.RowIndex >= 0 AndAlso e.ColumnIndex >= 0 Then
                    v = dgvIssues.Rows(e.RowIndex).Cells(1).Value.ToString
                    Debug.Print("v = " & v)
                End If
                'For x As Integer = 0 To Me.dgvIssues.SelectedCells.Count - 1
                '    Dim i As Integer
                '    i = dgvIssues.SelectedCells(x).RowIndex
                '    v = dgvIssues.Rows(i).Cells(1).Value.ToString
                '    Debug.Print(v)
                'Next
            Catch f As Exception
                MessageBox.Show(f.Message)
            End Try
            frmIssue.Show()
        End If
Posted
Updated 21-Feb-18 5:19am

1 solution

If you can't use a debugger - and my Win 10 tablet will run Visual Studio so you could just install it and give it a try - then you will have to fall back on older methods: logging. Add logging code to the relevant methods (File.AppendLine will do it) and narrow down the method that fails, and then the line(s) that cause the problem. Then log all the variables and see what values you are working with.
Yes, it's slow - but it's all we had in the old days, and it works! It's just you have to think in advance more carefully about what needs to be logged and what doesn't.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900