|
-
Sep 21st, 2009, 10:53 AM
#1
[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.
-
Sep 21st, 2009, 11:13 AM
#2
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 -
-
Sep 21st, 2009, 11:38 AM
#3
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.
-
Sep 21st, 2009, 11:55 AM
#4
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 -
-
Sep 21st, 2009, 12:05 PM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|