Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Check gridView "saved" status
 

Check gridView "saved" status

Hi, please help if anyone know..

I have a gridView..

I want to check the gridview before the form is close:
if the gridview had been saved before, and no changes, i won't ask whether user want to save it again..
if the gridview not yet saved before, i will prompt user whether they want to save the data..

How can i do that?
Looking for your help..

Thanks.~
wonderfulStar  Tuesday, May 19, 2009 2:21 AM
I mean- Please create your own Property of Form for this.
            private bool dirtyFlag = false;

            public bool DirtyFlag            
           {
                get
                {
                    return dirtyFlag;
                }
                set
                {
                    dirtyFlag = value;
                }
            }
Yes, you can use the event: _CellValueChanged to track modifications done in datagrid's cellvalues.
Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, May 22, 2009 8:35 AM
Is my question not understandable?

ok, this way:

I have a grid view which will showing data to user dynamically..
User can click "Save" button to save the data..

When user close the form, it will check whether the data is been saved or not..
if data had been saved (latest changes), save dialogbox will not prompt to user..
if data not been saved yet, save dialog box will prompt to user..

Looking forwards for anyone's reply..

Thanks..
wonderfulStar  Friday, May 22, 2009 1:37 AM

I think, I have understood your requirement. Well, you can try the following.

1. On you form, have a property: bool dirtyFlag. By default it's value is false.
2. When the gird load's, set dirtyFlag = false;
3. With every modifications done in the datagrid values, set dirtyFlag = true; in the appropriate events of datagrid.
4. When ever the user saves the changes made to datagrid, set dirtyFlag = false;
5. Now, add the condition - if(dirtyFlag == true) during Form closing. This condition checks if the datagrid modifications have been saved or not.

if(dirtyFlag == true)
{
...Changes haveNOT been saved...
}
else
{
...Changes have been saved...
}


Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, May 22, 2009 1:57 AM

do u means need declare our own variable "dirtyFlag"?
or do u means form's property called "dirtyFlag"? i cant found it under the Form's property..

and for the steps 3, how we can check for changing in gridview's value?
do any methods or events provided that can use directly to detect changes in gridview?

thanks

wonderfulStar  Friday, May 22, 2009 7:31 AM
I mean- Please create your own Property of Form for this.
            private bool dirtyFlag = false;

            public bool DirtyFlag            
           {
                get
                {
                    return dirtyFlag;
                }
                set
                {
                    dirtyFlag = value;
                }
            }
Yes, you can use the event: _CellValueChanged to track modifications done in datagrid's cellvalues.
Regards, Lakra :) - If the post is helpful or answers your question, please mark it as such.
Abhijeet Lakra  Friday, May 22, 2009 8:35 AM

You can use google to search for other answers

Custom Search

More Threads

• Hello there!
• Property returning an Object (ExpandableObjectConverter, Default Values...)
• Crazy PrintPreviewDialog not in intellisense
• Adding image resource causes design view error
• designer bugs
• Looks like a bug in VS 2005 Team Edition
• Change the boder colour in datagridview
• DataGridView Problem
• VS 2005 Bug - Split Container and Tab Control
• Custom DataGridView Columns