473,322 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

DataGrid with DataSet Closing Form Validation

I'm trying to detect if there are any unsaved changes in a
dataset when a user hits close form button (top right hand
corner).

My problem is that HasChanges does not detect a row that
has been modified if the cursor has not "left" that row
after modification. So if I edit a cell in a row of the
datagrid and then immediately click on close form, the
dataset has no changes, yet it really should.

i have tried setting focus to another control before
checking the haschanges, but still get the same result. i
have also tried setting the current row index of the
datagrid away from the row to try and "trick" it or
emulate me moving out of that row, but it still does not
work.

Has anyone had to deal with a similar problem ??
Sample code below:

private void UnsoladViewer_Closing(object sender,
System.ComponentModel.CancelEventArgs e)

{

DialogResult dr = DialogResult.None;

if (dsUnsolad.HasChanges())
{
dr = MessageBox.Show ("There are outstanding
changes. " + "Click YES to save changes." , "Unsolad
Modified", MessageBoxButtons.YesNoCancel);

switch (dr)
{
case DialogResult.Yes:
SaveData();
e.Cancel = false;
break;
case DialogResult.No:
e.Cancel = false;
break;
default:
e.Cancel = true;
break;
}
}
}
Jul 21 '05 #1
0 1282

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: thead01 | last post by:
I create a dataset, load xmlfile, create dataview (ds.defaultview) and bind it to a datagrid (dataset haschanges property is now 'true'). When a user closes the form I want to check via...
3
by: Brad | last post by:
I'm working with a DataGrid in C#, and the user needs to be able add and remove columns from the DataGrid on the fly, without opening and closing the form. The scenario is this. I have a setup...
4
by: Luis Esteban Valencia | last post by:
I have a asp.net page (C#), with a datagrid. I use template for all columns, and have <asp:requiredfieldvalidator> in with one of the textboxes, to make sure it's filled in. However, this...
4
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to...
2
by: Tom | last post by:
How is the best way to avoid validation when closing a window? For instance, I have a Windows Forms window which has a validation event for a text box. However, if one enters invalid data in then...
0
by: Michael Dimento | last post by:
I'm trying to detect if there are any unsaved changes in a dataset when a user hits close form button (top right hand corner). My problem is that HasChanges does not detect a row that has been...
9
by: mfahnestock | last post by:
Hi all! Aspiring VB programmer losing hair <And Sleep> over this problem. I have spent several days researching through the various usenets and resources to no avail, and so now I am taking the...
0
by: Patty05 | last post by:
I have a datagrid on a form that update properly when form loads. When the program runs and I type in/add a new row in the datagrid, it does not save the changes. Any help would be greatly...
2
by: SePp | last post by:
Hi all. I want to refresh a Datagrid from another form. For Example I have a Datagrid in that I want to edit data. The user has the ability to press a button to change these data. A new Form...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.