
Jeff Clark
Top achievements
Rank 1
Jeff Clark
asked on 28 Jul 2011, 08:01 PM
Is there an easy way to determine if the open document has any changes?
I want to prompt the user to see if they want to save the document when they try to close the document or open a new one, but only if the document has changed.
Thanks.
I want to prompt the user to see if they want to save the document when they try to close the document or open a new one, but only if the document has changed.
Thanks.
4 Answers, 1 is accepted
0
Hello Jeff,
Thank you for writing.
You can determine whether a document has been changed by subscribing to the DocumentContentChanged event of the desired document.
I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
All the best,
Stefan
the Telerik team
Thank you for writing.
You can determine whether a document has been changed by subscribing to the DocumentContentChanged event of the desired document.
I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
All the best,
Stefan
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0

Jeff Clark
Top achievements
Rank 1
answered on 15 Aug 2011, 07:17 PM
Thanks for the reply.
I created an event hanlder as follows:
Form Constructor
Event Handler
But the event handler is not firing when changes are made in the document. What am I doing wrong? Thanks.
I created an event hanlder as follows:
Form Constructor
public
frmEditEmail()
{
InitializeComponent();
radRichTextBox1.Document.DocumentContentChanged +=
new
EventHandler(Document_DocumentContentChanged);
}
Event Handler
void
Document_DocumentContentChanged(
object
sender, EventArgs e)
{
emailTextChanged =
true
;
MessageBox.Show(
"DocumentContentChanged"
);
}
But the event handler is not firing when changes are made in the document. What am I doing wrong? Thanks.
0
Accepted
Hello Jeff,
Thank you for writing.
I have tested this scenario and on my end it behaves correctly. A possible reason for which the event does not fire is if the document does not exist in the form's constructor. This is why, I would recommend that you subscribe to the event in the form Shown event (refer to the attached video). If this still does not work for you, please provide me with a sample project demonstrating the issue, so I can investigate it locally and provide you with adequate support.
I am looking forward to your reply.
All the best,
Stefan
the Telerik team
Thank you for writing.
I have tested this scenario and on my end it behaves correctly. A possible reason for which the event does not fire is if the document does not exist in the form's constructor. This is why, I would recommend that you subscribe to the event in the form Shown event (refer to the attached video). If this still does not work for you, please provide me with a sample project demonstrating the issue, so I can investigate it locally and provide you with adequate support.
I am looking forward to your reply.
All the best,
Stefan
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Accepted

Jeff Clark
Top achievements
Rank 1
answered on 02 Sep 2011, 09:54 PM
Thanks. Subscribing to the event in the Shown event didn't work, but that is because I haven't assigned a document to the RadRichText control yet. I subscribed to the event right after assigning a document to the control and now it is working.
Thanks for your help.
Thanks for your help.