Thanks, that is what I was expecting, but this all happens after the code has automatically saved the changes with SaveToFile. More detail, sorry I should have included this first: here is a fuller snippet of the code.
The user selects a new item from the list then this code is called:
if (dirty1)
{
ts = new Nevron.Nov.Test.Formats.NTextSaveSettings();
tvKey.SaveToFile(sDocPath + "My Keynotes" + System.IO.Path.DirectorySeparatorChar + OldRemedy.user.rtfd", tf, ts);
dirty1 = false;
}
if (ov.SelectedRow > -1)
{
BookChap bc = (BookChap)ov.ItemAtRow(ov.SelectedRow);
sRTF = sResPath + "My Keynotes/";
Nevron.Nov.Text.Formats.NTextFormat tf = new Nevron.Nov.Text.Formats.NRtfTextFormat();
if (System.IO.File.Exists(sDocPath + "My Keynotes" + System.IO.Path.DirectorySeparatorChar + <bc.Name>.user.rtfd"))
{
sRTF = sDocPath + "My Keynotes" + System.IO.Path.DirectorySeparatorChar + <bc.Name>.user.rtfd");
tvKey.LoadFromFile(sRTF, tf, false);
}
else
{
sRTF = "";
tvKey.LoadNewDocument();
}
}
I am tracking changes to the control using the dirty1 bool flag. When the user selects a new item from the list, it saves the old file automatically if there are changes. I hope you can see that the code saves the file then tries to load the new file. If the user was looking at a pre-existing file loaded with LoadFromFile, all is ok. The problem occurs if he selects an item from the list that does not currently have a file associated - a new document is loaded using LoadNewDocument - and the user then types something into the blank document. Finally he selects another item from the list - the code above saves the changes into a new file, then loads the newly selected item, and then I see the "Save, Don't Save, Cancel" dialog. After the file has saved successfully. How can I suppress this? I guess the real question is, how do I change the "modified state" of the old document before I try and load the new one?
Thanks