Set the caret position to specific offset.

8 posts, 0 answers
  1. Rotem
    Rotem avatar
    25 posts
    Member since:
    Sep 2010

    Posted 16 Nov 2011 Link to this post

    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.

    (http://www.telerik.com/help/silverlight/telerik.windows.documents-telerik.windows.documents.documentposition_members.html)

    Thanks,

    Rotem.

  2. Boby
    Admin
    Boby avatar
    595 posts

    Posted 22 Nov 2011 Link to this post

    Hello Rotem,
    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();
    }
    You can read more about positioning in this article.
    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Vikash
    Vikash avatar
    12 posts
    Member since:
    Apr 2012

    Posted 27 Apr 2012 Link to this post

    How to set tabindex in richtextbox.I am setting like given sample code.It not working properly.richtextbox tab comes after button tab.
    <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"/>
  5. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 02 May 2012 Link to this post

    Hi Vikash,

    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 >>

  6. Vikash
    Vikash avatar
    12 posts
    Member since:
    Apr 2012

    Posted 24 May 2012 Link to this post

    Hi Telerik Team,

    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>
  7. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 28 May 2012 Link to this post

    Hello Vikash,

    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 >>

  8. Vikash
    Vikash avatar
    12 posts
    Member since:
    Apr 2012

    Posted 14 Jun 2012 Link to this post

    Hi Team,
    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.
  9. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 19 Jun 2012 Link to this post

    Hi Vikash,

    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 >>

Back to Top
UI for WPF is Visual Studio 2017 Ready