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

Counting List Level in RadRichTextBox

3 Answers 68 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Ashrul
Top achievements
Rank 1
Ashrul asked on 15 May 2018, 09:23 AM

hi, i m ashrul,

i m working in RadRichTextBox right now, i want to ask about liststyle, how we can count listlevel dinamically when user typing ang using listlevel..

here my snippet:

 

  private void Button_Click(object sender, RoutedEventArgs e)
        {

            RadDocument document = this.editor.Document;
            RadDocumentEditor editor = new RadDocumentEditor(document);
            ListStyle listStyle = new ListStyle();
            ListLevelStyle listLevel = new ListLevelStyle();

            MessageBox.Show(listLevel.ToString());
        }

 

 

thanks in advance

3 Answers, 1 is accepted

Sort by
0
Anna
Telerik team
answered on 18 May 2018, 05:10 AM
Hi,

I am not completely sure I understand what you would like to do. If you want to find what is the level of the current text the user is on you can do it like this:

Paragraph paragraph = document.CaretPosition.GetCurrentParagraphBox().AssociatedParagraph;
int level = paragraph.ListLevel;
 
MessageBox.Show(level.ToString());

On the other hand, if you want to find the deepest level of the list, you can iterate the paragraphs like this:

int maxLevel = 0;
 
foreach (Paragraph par in document.EnumerateChildrenOfType<Paragraph>())
{
    int level = par.ListLevel;
 
    if (level > maxLevel)
    {
        maxLevel = level;
    }
}
 
MessageBox.Show(maxLevel.ToString());

I hope this answers your question. Please, let me know if you had something else in mind.

Regards,
Anna
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Ashrul
Top achievements
Rank 1
answered on 22 May 2018, 03:41 AM

hi Anna, thanks for your response.

can you explain to me about line :

Paragraph paragraph = document.CaretPosition.GetCurrentParagraphBox().AssociatedParagraph;

what is CaretPosition,GetCurrentParagraphBox, and AssociatedParagraph.

i found nothing in documentation thats make me understand.


thanks in advanced.

0
Boby
Telerik team
answered on 23 May 2018, 08:52 AM
Hi Ashul,

You can read about this topic in the Positioning article.

Regards,
Boby
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
RichTextBox
Asked by
Ashrul
Top achievements
Rank 1
Answers by
Anna
Telerik team
Ashrul
Top achievements
Rank 1
Boby
Telerik team
Share this question
or