Hellow,
I have code for DataGridView1_CellContentDoubleClick to edit row from another form as
It works well.
Now if I want to execute this code on Button Click named as BtnEdit witch is outside of datagridview.
when I copied this code to BtnEdit it gives error to following line -
Dim cells = DataGridView1.Rows(e.RowIndex).Cells
'e' is not declared. It may be inaccessible due to its protection level.
How to solve this error ?
Thanks in advance.
I have code for DataGridView1_CellContentDoubleClick to edit row from another form as
VB.NET:
Private Sub DataGridView1_CellContentDoubleClick(sender As Object, e As DataGridViewCellEventArgs) Handles DataGridView1.CellContentDoubleClick
Dim cells = DataGridView1.Rows(e.RowIndex).Cells
Using dialogue As New FrmAddItemsNew
With dialogue
.TxtTestID.Text = cells(0).Value.ToString()
.TxtInvoiceID.Text = cells(1).Value.ToString()
.TxtProductID.Text = cells(2).Value.ToString()
.CmbProductName.Text = CStr(cells(3).Value)
.TxtHSN.Text = cells(4).Value.ToString()
.TxtSerialNo.Text = cells(5).Value.ToString()
.TxtUnit.Text = cells(6).Value.ToString()
.TxtQty.Text = cells(7).Value.ToString()
.TxtInclRate.Text = cells(8).Value.ToString()
.TxtBaseRate.Text = cells(9).Value.ToString()
.TxtAmount.Text = cells(10).Value.ToString()
.TxtGST.Text = cells(11).Value.ToString()
.TxtGSTAmt.Text = cells(12).Value.ToString()
.TxtTotal.Text = cells(13).Value.ToString()
.BtnEdit.Visible = True
'.BtnEdit.Enabled = False
If .ShowDialog() = DialogResult.OK Then
cells(0).Value = .TxtTestID.Text
cells(1).Value = .TxtInvoiceID.Text
cells(2).Value = .TxtProductID.Text
cells(3).Value = .CmbProductName.Text
cells(4).Value = .TxtHSN.Text
cells(5).Value = .TxtSerialNo.Text
cells(6).Value = .TxtUnit.Text
cells(7).Value = .TxtQty.Text
cells(8).Value = .TxtInclRate.Text
cells(9).Value = .TxtBaseRate.Text
cells(10).Value = .TxtAmount.Text
cells(11).Value = .TxtGST.Text
cells(12).Value = .TxtGSTAmt.Text
cells(13).Value = .TxtTotal.Text
End If
End With
End Using
End Sub
Now if I want to execute this code on Button Click named as BtnEdit witch is outside of datagridview.
when I copied this code to BtnEdit it gives error to following line -
Dim cells = DataGridView1.Rows(e.RowIndex).Cells
'e' is not declared. It may be inaccessible due to its protection level.
How to solve this error ?
Thanks in advance.