Results 1 to 3 of 3

Thread: Can only edit NULL cells in DataGridView

  1. #1
    chris_asa is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    24
    Reputation
    51

    Can only edit NULL cells in DataGridView

    I usually populate DataGridViews manually from a disconnected DataTable.
    It works, but it is ...well, boringly manual.

    Today I'm experimenting with binding a DGV to the disconnected datatable.

    I have a class with some simple properties plus a datatable.
    e.g.

    Code:
    Friend Class oCase
    
      'a simple property
      Private pCaseID as integer = 0
      Friend property CaseID() as integer
        get
          return pCaseID
        end get
        set (byval value as integer)
          pCaseID = value
        end set
      end property
    
      'a datatable
      Friend myDT as datatable = New datatable
    
    End class
    Elsewhere: Friend CurrentCase as oCase = New oCase and SQL-Server stored procedure ---> DataReader ---> CurrentCase.myDT
    In a form with a DataGridview named dgvCaseInfo I can manually populate/harvest the DGV from/to DT, save DT back to DB. Everything works.

    So on with the DGV binding experiment
    Comment out the populate/harvest and try:
    dgvCaseInfo.Datasource = CurrentCase.myDT

    dgvCaseInfo is populated as desired

    BUT

    In dgvCaseInfo, any cell containing a value that was not NULL in the db just wont let me in.
    I *CAN* edit any cell that was NULL in the db.
    Once I enter a value in one of the NULL cells, that cell wont let me in a second time.

    By "wont let me in" I mean that the cell is unclickable once it has a non-NULL value (either from the db, or from edits I have made). Tabbing or arrowing skips non-NULL cells.

    What have I misunderstood?

    regards Chris

  2. #2
    chris_asa is offline VB.NET Forum Newbie
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Sep 2009
    Location
    Switzerland
    Posts
    24
    Reputation
    51

    Fixed

    There must have been some property or other "left over" from the formerly manually populated/harvested DGV.
    Deleting the DGV from the form and adding a new DGV fixed it.

    regards Chris

  3. #3
    Paszt's Avatar
    Paszt is offline VB.NET Forum Moderator
    .NET Framework
    .NET 4.0
    Join Date
    Jun 2004
    Location
    Raleigh, NC - USA
    Posts
    1,502
    Reputation
    308
    Creating a DataView (ADO.NET): Dim custDV As DataView = custDS.Tables("Customers").DefaultView

    DataTable.DefaultView Property (System.Data)
    — Stephen Paszt

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking