Ticket T184353
Visible to All Users
Duplicate

Restoring VerticalScrollPosition

created 10 years ago

This code doesn't work for me.

C#
var vsp = srLiveView.RichEditControlAce.VerticalScrollPosition; srLiveView.RichEditControlAce.RtfText = documentServer.RtfText; srLiveView.RichEditControlAce.VerticalScrollPosition = vsp;

although VSP is a number in the thousands, setting VerticalScrollPosition doesn't do anything and just remains at 0.
Do I need to do something else to poke it into building the document before setting a VerticalScrollPosition?

Is there a better way?

documentServer builds up a document and assigns it to srLiveView.RichEditControlAce as a 'live' preview.
Uses clicks a checkbox which results in generated document adding or removing a page or section.
Would like to have the 'live' view stay showing what the user last scrolled to instead of blindly going back to the top of the document.

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

This doesn't work because a document isn't ready to accept a new scrolling position right after loading. Use RichEditControl's DocumentLoaded event to assign the scrolling position.

C#
private long vsp = 0L; private void Form1_Load(object sender, EventArgs e) { richEditControl1.DocumentLoaded += richEditControl1_DocumentLoaded; richEditControl1.LoadDocument("Lorem.docx"); } private void simpleButton1_Click(object sender, EventArgs e) { vsp = richEditControl1.VerticalScrollPosition; using ( RichEditDocumentServer ds = new RichEditDocumentServer() ) { ds.RtfText = richEditControl1.RtfText; ds.Document.InsertSection(ds.Document.Range.End); richEditControl1.RtfText = ds.RtfText; } } private void richEditControl1_DocumentLoaded(object sender, EventArgs e) { richEditControl1.VerticalScrollPosition = vsp; }
    Show previous comments (2)

      Just found this doesn't work when multiple pages are visible side-by-side.
      The effect I am trying to achieve is to show a generated Document as a live preview. The user cannot modify this document directly but can zoom in and scroll up and down. When a new RtfText is assigned (created externally but likely to be very similar - paragraph added or removed etc.), I want the preview layout pages to be exactly the same - same size, same position, same scrollbars etc.
      It should seem that just the content of the pages changes.

      DevExpress Support Team 9 years ago

        Hello Simon,
        I was able to reproduce the issue. It appears that we need additional time to research it.
        Please bear with us, we will get back to your as soon as possible.

        DevExpress Support Team 9 years ago

          Hi Simon,
          I have created a separate ticket on your behalf regarding this issue and passed that ticket to our developers so that they can fix this issue.
          Please bear with us. We will update the status of the following ticket once we have any results:
          Restoring the VerticalScrollPosition property value operates incorrectly in the case of a "multi-page" document layout

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.