Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
The Problem is that
I have a dataGridView and Some text boxes
I fill the textboxes and the click a add button
which add a row in dataridview having the values i enterd in textboxes like
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click

       Dim c As Integer
       c = dgv.Rows.Count

       dgv.Rows.Add()

       dgv.Rows(c).Cells(0).Value = lblTID.Text
       dgv.Rows(c).Cells(1).Value = txtSlNo.Text.ToString()
       dgv.Rows(c).Cells(2).Value = cmbItem.Text.ToString()
       dgv.Rows(c).Cells(3).Value = IIf(cmbItem.SelectedIndex > -1, cmbItem.SelectedIndex + 1, Nothing)
       dgv.Rows(c).Cells(4).Value = txtItCode.Text.ToString()
       dgv.Rows(c).Cells(5).Value = txtQty.Text.ToString()
       dgv.Rows(c).Cells(6).Value = txtDesc.Text.ToString()

   End Sub



Next I click on datagrid Row and get back the Values Inside textboxes as
Private Sub dgv_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgv.CellClick
        Dim i As Integer
        i = dgv.CurrentRow.Index
        'If dgv.Item(1, i).Value = txtSlNo.Text Then

        'End If
        lblTID.Text = dgv.Item(0, i).Value
        txtSlNo.Text = dgv.Item(1, i).Value
        cmbItem.Text = dgv.Item(2, i).Value
        lblItemId.Text = dgv.Item(3, i).Value
        txtItCode.Text = dgv.Item(4, i).Value
        txtQty.Text = dgv.Item(5, i).Value
        txtDesc.Text = dgv.Item(6, i).Value
    End Sub



And then my Problem is that after getting the values back in textboxes from Dataridview.... I want to edit the values of textboxes and agin need to add that...
But hte requirement is that it should not add any new row to the datagridview but
just change the values what i edited in the textboxes,

Can this is possible.
please assist
Posted

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