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

About VerticalScrollBar property

3 Answers 77 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Alberto Mesa
Top achievements
Rank 1
Alberto Mesa asked on 24 Mar 2011, 02:41 AM

I am opening documents (Q3 sp1 2010) and I am looking for expressions for changing theirs background. This is the code:

 

 

 

deltaY = rtb.VerticalScrollBar.Value;        // page 1

.

.

 

 

this.rtb.Document.CaretPosition.MoveToPosition(end);    // page 5

 

.
.
this
.rtb.ChangeTextHighlightColor(Color));
.
.

 

rtb.VerticalScrollBar.Value = deltaY;    // page 1 but does not show content of page 1

 

 

The scrollbar takes the saved value but the page does not change to the corresponding position as the verticalScrollbar.Value. How can I synchronize them?

 

3 Answers, 1 is accepted

Sort by
0
Andrew
Telerik team
answered on 25 Mar 2011, 02:49 PM
Hi Alberto Mesa,

 Unfortunately, for now, we do not support scroll bar manipulation. We are planning to introduce this kind of API in one of our forthcoming minor releases. We hope we can include it in the service pack which is due around April 15.

I can think of only one solution to this problem in your case, and that's to store the position of the Caret. To go to the end of the document, do some stuff, and then return the caret to it's original position.
Here is the code:

DocumentPosition currentDocumentPosition = new DocumentPosition(rtb.Document.CaretPosition);
  
this.rtb.Document.CaretPosition.MoveToLastPositionInDocument();
  
.
.
this.rtb.ChangeTextHighLightColor(Color);
.
.
  
this.rtb.Document.CaretPosition.MoveToPosition(currentDocumentPosition);

If you have any other requests or questions, please contact us again.

Regards,
Andrew
the Telerik team
0
Alberto Mesa
Top achievements
Rank 1
answered on 26 Mar 2011, 01:41 AM
Thanks for reply. This solution helps but not completely because if you move the document by scrolling this code does not work, it just works respecting about the last caret position and not the scroll position. Any other idea?
0
Mike
Telerik team
answered on 30 Mar 2011, 04:24 PM
Hello Alberto Mesa,

We will add an item in our todo-list regarding this functionality for the next minor release (SP1) which should be delivered in a few weeks. I am afraid for now the only option is the one we already discussed.

Kind regards,
Mike
the Telerik team
Tags
RichTextBox
Asked by
Alberto Mesa
Top achievements
Rank 1
Answers by
Andrew
Telerik team
Alberto Mesa
Top achievements
Rank 1
Mike
Telerik team
Share this question
or