Changed event raised when loading documents with Header/Footer

2 posts, 0 answers
  1. Rob
    Rob avatar
    238 posts
    Member since:
    Jan 2009

    Posted 03 Dec 2012 Link to this post

    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
  2. Vasil
    Admin
    Vasil avatar
    124 posts

    Posted 06 Dec 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top