Results 1 to 5 of 5

Thread: [RESOLVED] DataSet.HasChanges not firing unless you leave row

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Resolved [RESOLVED] DataSet.HasChanges not firing unless you leave row

    When you edit a cell in a datagrid, how can you "commit" that change if you are still in that current cell? Right now, the DataSet.HasChanges property isn't true UNTIL you leave the current cell. If you don't click on another row, then the property is not true yet. How can I tell it that it is true without physically clicking on another cell?
    Last edited by gigemboy; Sep 21st, 2009 at 11:01 AM.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: DataSet.HasChanges not firing unless you leave row

    Is it a datagrid or DataGridView? If it's the later, you can call the Commit method on the DGV to force it to commit the changes to its datasource. However, you're biggest problem is to detect when to call the method unless you have something to look for, such as the enter key...
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: DataSet.HasChanges not firing unless you leave row

    I am using a datagridview control in a windows form. There is no Commit method that I see. There is a CommitEdit, which I have tried, but it seems to have no effect. I just have that one control by itself on the form and wish to check for changes and prompt to save if there are (only other controls are menu items), and it is working, unless you only make one change and do not leave the row. It doesn't prompt since the Dataset.HasChanges property is not true.

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: DataSet.HasChanges not firing unless you leave row

    Yeah, I meant the CommitEdit method... From the sound of what you are doing, you may want to test the DGV.IsCurrentRowDirty property, and if it is, you call the form's Validate method to commit the changes to the datasource. If the datasource is a bindingsource, you can call BS.EndEdit instead.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: DataSet.HasChanges not firing unless you leave row

    That seems to be the step I was missing, calling .Validate on the form after ending the edits. Thanks.

Posting Permissions

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



Click Here to Expand Forum to Full Width