Hi,
I’m using RadRichText and I’m trying to move the caret to specific offset from the start of the document (or specific row and column).
I saw on the forum that in order to move the caret I need to use
richTextBox.Document.CaretPosition.MoveToPosition
That gets DocumentPosition as parameter. But I can’t create documentPosition from desired text position.
How can I set the caret position from the beginning of the document?
By the way,
The Document position API help page doesn’t work.
Thanks,
Rotem.
7 Answers, 1 is accepted
You can navigate the position to specific line/character using the following methods:
private
void
Button_Click(
object
sender, RoutedEventArgs e)
{
this
.radRichTextBox.Document.CaretPosition.MoveToFirstPositionInDocument();
// this will move the position down (to the next line)
this
.radRichTextBox.Document.CaretPosition.MoveDown();
// alternatively, you can use this combination to move to the next line start
//this.radRichTextBox.Document.CaretPosition.MoveToCurrentLineEnd();
//this.radRichTextBox.Document.CaretPosition.MoveToNext();
// this will move to the next position
this
.radRichTextBox.Document.CaretPosition.MoveToNext();
// return the focus to the RadRichTextBox
this
.radRichTextBox.Focus();
}
The DocumentPosition.MoveToPosition is useful if you want to move the caret to an instance of DocumentPosition, obtained for example from selection or search.
The actual link to the Document position members API is this one. Could you please share the page you've found invalid link on, so we can update it with the correct link?
All the best,
Boby
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
<
telerik:RadMaskedTextBox
TabIndex
=
"4"
Mask
=
""
MaskedText
=
""
MaskType
=
"None"
Name
=
"txtTerms"
FontFamily
=
"Verdana"
Margin
=
"132.991,151.144,12,0"
VerticalAlignment
=
"Top"
d:LayoutOverrides
=
"HorizontalAlignment"
ValueChanged
=
"txtTerms_ValueChanged"
/>
<
telerik:RadRichTextBox
TabIndex
=
"5"
Name
=
"rtbDescription"
DocumentInheritsDefaultStyleSettings
=
"True"
AcceptsTab
=
"True"
IsSpellCheckingEnabled
=
"False"
IsEnabled
=
"True"
FontFamily
=
"Verdana"
Margin
=
"132.991,186.287,10,0"
Height
=
"145"
VerticalAlignment
=
"Top"
>
</
telerik:RadRichTextBox
>
<
telerik:RadButton
TabIndex
=
"6"
Content
=
"Save"
Style
=
"{DynamicResource greenbutton}"
Name
=
"btnSave"
C ursor
=
"Hand"
HorizontalAlignment
=
"Right"
Margin
=
"0,392,201,0"
FontFamily
=
"Verdana"
Width
=
"49"
Foreground
=
"White"
BorderBrush
=
"{x:Null}"
BorderThickness
=
"0"
Height
=
"22"
VerticalAlignment
=
"Top"
Click
=
"btnSave_Click"
/>
Indeed this is a bug in RadRichTextBox and we will try to fix it as soon as possible. We updated your Telerik points in appreciation for your involvement.
All the best,Andrew
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
How to apply theme in RadRichTextBox.I am using this code:But it not working
<
telerik:RadRichTextBox
IsTabStop
=
"False"
TabIndex
=
"2"
Name
=
"rtbDescription"
telerik:StyleManager.Theme
=
"Expression_Dark"
DocumentInheritsDefaultStyleSettings
=
"True"
AcceptsTab
=
"True"
IsSpellCheckingEnabled
=
"False"
IsEnabled
=
"True"
FontFamily
=
"Verdana"
Height
=
"145"
VerticalAlignment
=
"Top"
Margin
=
"12,203,131,0"
>
</
telerik:RadRichTextBox
>
You need to add a reference to the appropriate theme assembly. In your case that would be Telerik.Windows.Themes.Expression_Dark.dll. Furthermore, in order to have the theme apply to all pop-ups that the editor uses, the theme should be set on application level before the UI is created (i.e. before InitializeComponent()):
StyleManager.ApplicationTheme =
new
Expression_DarkTheme();
You can see how the editor looks like when this theme is applied in the Theming example of the ClickOnce demos. Kind regards,
Andrew
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Can you please sent me a sample project to apply theme in RadRichTextBox. I am applying
StyleManager.ApplicationTheme = new Expression_DarkTheme(); in App.xaml.cs at Application_Startup event.Theme works fine on all other control except RadRichTextBox. Please reply ASAP.
We created a sample project where the Expression Dark theme is applied to RadRichTextBox and we are attaching it to this post. Please notice that the control is in Paged layout mode. If you change the mode to Flow for example, the scrollbars would be using the theme colors but the RadRichTextBox will remain white with black letters.
All the best,Andrew
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>