Click here to Skip to main content
15,891,633 members
Home / Discussions / C#
   

C#

 
GeneralRe: A simple Form OK button question Pin
Gogou10-Mar-03 12:02
Gogou10-Mar-03 12:02 
GeneralRe: A simple Form OK button question Pin
DionChen10-Mar-03 16:48
DionChen10-Mar-03 16:48 
GeneralRe: A simple Form OK button question Pin
James T. Johnson10-Mar-03 18:07
James T. Johnson10-Mar-03 18:07 
GeneralRe: A simple Form OK button question Pin
Zek3vil11-Mar-03 7:01
Zek3vil11-Mar-03 7:01 
GeneralRe: A simple Form OK button question Pin
LongRange.Shooter11-Mar-03 7:33
LongRange.Shooter11-Mar-03 7:33 
QuestionBackground color on a TreeView checkbox? Pin
se99ts10-Mar-03 10:35
se99ts10-Mar-03 10:35 
QuestionDataSet bind to datagrid, how to flush or reject changes on Form.Closing ? Pin
Chris Richner10-Mar-03 10:25
Chris Richner10-Mar-03 10:25 
AnswerRe: DataSet bind to datagrid, how to flush or reject changes on Form.Closing ? Pin
leppie10-Mar-03 10:39
leppie10-Mar-03 10:39 
Override on closing rather Wink | ;)

This what I did (in fact just yesterday):
<font  size=2 face="Courier New"><font color="#0000FF">protected </font><font color="#000000">override </font><font color="#0000FF">void </font><font color="#000000">OnClosing</font>(<font color="#000000">CancelEventArgs e</font>)
{
   <font color="#000000">DataSet ds </font>= <font color="#000000">dataSet1</font>.<font color="#000000">GetChanges</font>();

   <font color="#0000FF">if </font>(<font color="#000000">ds </font>!= <font color="#000000">null</font>)
   {
      <font color="#000000">DialogResult result </font>= <font color="#000000">MessageBox</font>.<font color="#000000">Show</font>(<font color="#0000FF">this</font>, 
<font color="#FFFFFF">	</font><font color="#FF8000">"Would you like to save " </font>+ <font color="#000000">datafile </font>+ <font color="#FF8000">" ?"</font>, <font color="#FF8000">"Confirm save file..."</font>,
         <font color="#000000">MessageBoxButtons</font>.<font color="#000000">YesNoCancel</font>, <font color="#000000">MessageBoxIcon</font>.<font color="#000000">Question</font>);

      <font color="#0000FF">switch </font>(<font color="#000000">result</font>)
      {
         <font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">Yes</font>:
            <font color="#000000">SaveXml</font>(<font color="#000000">datafile</font>);
            <font color="#0000FF">break</font>;
         <font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">No</font>:
            <font color="#0000FF">break</font>;
         <font color="#0000FF">case </font><font color="#000000">DialogResult</font>.<font color="#000000">Cancel</font>:
            <font color="#000000">e</font>.<font color="#000000">Cancel </font>= <font color="#0000FF">true</font>;
            <font color="#0000FF">break</font>;
      }
   }
   <font color="#000000">base</font>.<font color="#000000">OnClosing</font>(<font color="#000000">e</font>);
}
</font>
SaveXml() is just a method I have to save the XML and datafile is a string that is the file's full path and name.

Hope this helps Smile | :)

[edit] I just realize its almost the same, except perhaps that you are using the event rather than overriding, and that you call GetChanges(). Never did try that Poke tongue | ;-P How do you persist (load/save) the dataset anyways? Are you not calling AcceptChanges somewher in between, that would cause it to return false more than often. I call AcceptChanges only one after I have read the XML from a file.[/edit]

I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
GeneralRe: DataSet bind to datagrid, how to flush or reject changes on Form.Closing ? Pin
Chris Richner10-Mar-03 22:48
Chris Richner10-Mar-03 22:48 
GeneralRe: DataSet bind to datagrid, how to flush or reject changes on Form.Closing ? Pin
ed2d11-Mar-03 21:25
ed2d11-Mar-03 21:25 
GeneralRe: DataSet bind to datagrid, how to flush or reject changes on Form.Closing ? Pin
Chris Richner12-Mar-03 5:08
Chris Richner12-Mar-03 5:08 
QuestionGet xpath of current Node? Pin
Bog10-Mar-03 10:00
Bog10-Mar-03 10:00 
AnswerRe: Get xpath of current Node? Pin
Christian Graus10-Mar-03 10:08
protectorChristian Graus10-Mar-03 10:08 
GeneralDrawing my own tab... Pin
Gogou10-Mar-03 9:35
Gogou10-Mar-03 9:35 
GeneralRe: Drawing my own tab... Pin
leppie10-Mar-03 9:50
leppie10-Mar-03 9:50 
GeneralRe: Drawing my own tab... Pin
Gogou10-Mar-03 10:12
Gogou10-Mar-03 10:12 
Question3 State Treeview checkboxes? Pin
vlusardi10-Mar-03 6:25
vlusardi10-Mar-03 6:25 
AnswerRe: 3 State Treeview checkboxes? Pin
Stephane Rodriguez.10-Mar-03 9:41
Stephane Rodriguez.10-Mar-03 9:41 
GeneralRecursive File Search Pin
Mark Sanders10-Mar-03 5:42
Mark Sanders10-Mar-03 5:42 
GeneralRe: Recursive File Search Pin
Mazdak10-Mar-03 7:57
Mazdak10-Mar-03 7:57 
GeneralRe: Recursive File Search Pin
leppie10-Mar-03 10:02
leppie10-Mar-03 10:02 
GeneralRe: Recursive File Search Pin
Mazdak11-Mar-03 6:59
Mazdak11-Mar-03 6:59 
GeneralRe: Recursive File Search Pin
Mark Sanders10-Mar-03 10:39
Mark Sanders10-Mar-03 10:39 
GeneralRe: Recursive File Search Pin
Mazdak11-Mar-03 7:30
Mazdak11-Mar-03 7:30 
GeneralRe: Recursive File Search Pin
Mark Sanders14-Mar-03 12:04
Mark Sanders14-Mar-03 12:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.