This is a migrated thread and some comments may be shown as answers.

Changed event raised when loading documents with Header/Footer

1 Answer 51 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 03 Dec 2012, 05:45 PM
We are experiencing a problem with the RadRichTextBox.

It seems that the "DocumentContentChanged" event fires when we simply load a document that contains a header or footer. If we load a document without a header / footer, the event does not fire.

In our app, this causes problems because users are told the document is "dirty" and will need to save it...

In case it's relevant, we are using version 2012.3.1023.1050.

Thanks,
Rob

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 06 Dec 2012, 03:15 PM
Hi Rob,

Indeed DocumentContentChanged event is raised when header/footer is presented in the imported document. This is a known issue for us, but unfortunately, it's not scheduled for fixing yet. However, you can track our progress and vote for it in our public issue tracking system here.
As a workaround you can subscribe to DocumentContentChanged event on first command executed after the document is changed (and also to ActiveDocumentEditorChanged event, to handle the case when user starts to edit the header/footer directly). For example:

public partial class MainPage : UserControl
    {
        private bool tracking;
  
        public MainPage()
        {
            InitializeComponent();
  
            this.radRichTextBox.DocumentChanging += (s, e) =>
            {
                this.tracking = false;
                this.radRichTextBox.DocumentContentChanged -= radRichTextBox_DocumentContentChanged;
            };
  
            this.radRichTextBox.CommandExecuting += (s, e) =>
            {
                if (!this.tracking && !(e.Command is OpenDocumentCommand) && !(e.Command is NewDocumentCommand))
                {
                    this.radRichTextBox.DocumentContentChanged += radRichTextBox_DocumentContentChanged;
                    this.tracking = true;
                }
            };
        }
  
        private void radRichTextBox_ActiveDocumentEditorChanged(object sender, EventArgs e)
        {
            if (!this.tracking)
            {
                this.radRichTextBox.DocumentContentChanged += radRichTextBox_DocumentContentChanged;
                this.tracking = true;
            }
        }
  
        private void radRichTextBox_DocumentContentChanged(object sender, EventArgs e)
        {
            MessageBox.Show("Content");
        }
  
        private void radRichTextBox_DocumentChanged(object sender, EventArgs e)
        {
            MessageBox.Show("Document");
        }
}
I hope this information helps. Please, let us know if we could provide further assistance.


All the best,
Vasil
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
RichTextBox
Asked by
Rob
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or