Edit Datagridview (cell)

IneedaSmoke

Active member
Joined
Mar 4, 2008
Messages
26
Programming Experience
Beginner
Hi all, got a q regarding datagridview. i'm trying to get some columns take in some user input and have that sent to my datatable. Not sure where I'm going wrong with this. I put in 3 msgbox, one to show column location, one to show row location and the third displaying the value of the cell.

The location show up correctly but the value does not. ds is the dataset and dt is teh table.

VB.NET:
 Private Sub datagridview1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellLeave
        MsgBox(e.ColumnIndex)
        MsgBox(e.RowIndex)

        Dim tempValue As New Object
        tempValue = DataGridView1(e.ColumnIndex, e.RowIndex).Value

        MsgBox(tempValue.ToString)
        Try

        Catch ex As Exception

        End Try

        If e.ColumnIndex <> 0 Then
            Try
                ds.Tables("dt").Rows(e.RowIndex).Item(e.ColumnIndex) = tempValue
            Catch ex As Exception

            End Try


        End If

       
       
    End Sub



Any suggestions? TIA
 
What does this code do? Read a value from a cell in a DGV and then write it to a datatable in the same location?

Note: because DGV can be sorted and their columns reordered, you can never be certain that Column/Row Index in a DGV is analogous to a Column/Row ordinal in a data table. DO NOT DO IT!
 
Back
Top