Additional information: Index -1 does not have a value.
I am creating data gestion program this form3 contains a DGV shows data from my MS Access DB and another DGV1 contains items from a list of objects.
The problem is when I click on any item of DGV1 the error shows and the program break
I tried it with another program and it works just fine
I will past the code of form here
Imports System.IO
Imports Newtonsoft.Json
Public Class Form3
Public Shared d As devis = New devis() 'creatig devis
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'DataATDataSet.DataArticl' table. You can move, or remove it, as needed.
Me.DataArticlTableAdapter.Fill(Me.DataATDataSet.DataArticl) 'fill DGV with data in db
devisBindingSource.DataSource = d.listArticle 'DGV1 data source list of article in devis d
DataGridView1.DataSource = devisBindingSource
End Sub
Private sRef As String 'variable to put selected row values
Private sNomArticle As String
Private sPU As String
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sRef = DataArticlDataGridView.CurrentRow.Cells(0).Value
sNomArticle = DataArticlDataGridView.CurrentRow.Cells(1).Value
sPU = DataArticlDataGridView.CurrentRow.Cells(2).Value
d.addArticle(sRef, sNomArticle, CDbl(sPU), CDbl(TextBox1.Text)) 'adding article to list
DataGridView1.DataSource = Nothing 'refreshing data source
DataGridView1.DataSource = devisBindingSource
DataGridView1.Refresh()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim savePath As String = Directory.GetCurrentDirectory + "/projects/" + Form1.projectName 'saving folder
File.WriteAllText(savePath + "/devis.json", JsonConvert.SerializeObject(d)) 'serialize object in json
MsgBox("Saved")
End Sub
End Class