editing datagridview cells

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • svibuk
    New Member
    • Dec 2008
    • 8

    editing datagridview cells

    Dim cmd As New SqlCommand(SQLS TR, conn)
    reader = cmd.ExecuteRead er()

    Dim myDataTable As New DataTable
    myDataTable.Loa d(reader)

    If myDataTable.Row s.Count > 0 Then

    datagridview1.D ataSource = myDataTable
    datagridview1.C olumns(2).Heade rText = "QUANTITY"

    datagridview1.A llowUserToAddRo ws = False
    datagridview1.E ditMode = DataGridViewEdi tMode.EditOnKey strokeOrF2

    datagridview1.F ocus()
    datagridview1.C urrentCell = datagridview1(2 , 0)
    datagridview1.B eginEdit(True)

    Else
    datagridview1.D ataSource = myDataTable
    End If

    m_reader.Close( )
    cmd.Dispose()

    i hve the follwoing code by which i bind the data to the grid
    the grid has 4 columns PRODUCTNAME, QTY,RATE, AMOUNT

    the user shld be able to edit the data in the column qty for as many rows it has
    but i m not able to edit this column
    how do i edit the values in the cells of column(1) ie qty
  • marcellus7
    New Member
    • Oct 2008
    • 33

    #2
    An easier way to do this would be to use the BindingSource tool. You can simply set your dataset to the BindingSource, and set your DataGrid datasource to the BindingSource, and it will automatically handle the functions that would allow a user to edit the data in the DataGrid, and you could modify it by just using the properties of the datagrid.

    Comment

    Working...