If you have taken a look at the blog post about the new features introduced in the latest Q1 2011 and have taken a liking to the multilevel lists, you should definitely read this one. It will give you some insight on the usage of the options that come out of box and some information on how you can extend them to suit the purposes of your project.
In case you are in the habit of starting reading from the end, you can preview the Silverlight demo to see the lists in action. You should note that there are buttons both in the RibbonBar and in the SelectionMiniToolBar for toggling lists on and off. You can also easily convert lists from one type to another using the list-style gallery from the Paragraph RibbonGroup in the Home Tab. Changing the list level at which a paragraph appears is done fairly simple, too, using the buttons with the cute arrows or the key-bindings that trigger the corresponding commands (Tab for increasing the indent and Shift + Tab for decreasing it). You can have up to 9 levels with the default lists, similarly to the ones in MS Word. Here is an example:
Lists can be created and inserted into a document programmatically just as easily. All you need to do is create a list and some paragraphs and add the paragraphs to the list at the list level you wish them to appear. The numbers and the bullet types are automatically taken care of for you. Here is a code-snippet to get you started:
You have predefined list styles at your disposal (the ones that appear in the list library) – Bulleted, Numbered, NumberedHierarchical (the one from the first screenshot), NumberedParenthesis (second screenshot) and None – which if used on paragraphs in a list will exclude them from the list.
The default list styles come handy, as they require little to no effort on your part, but if you find them plain, you are more than welcome to create your own using the API. You can quite easily create a bulleted list using bullets defined by you, a numbered list which uses Roman digits, or one that uses Arabic numbers, but does not include the number of the previous list item which is of a smaller level.
The functionality you need to use is located in the ListStyle and ListLevelStyle classes. Here are the steps you need to follow in order to create a new list:
So much for the theory, let’s see how a
list can be created in practice. Say you wish to have a numbered list
that has UpperRoman letters at all levels and each level includes the
number of the item that is its predecessor. Here is the code to achieve
public void RegisterUpperRomanHierarchicalListStyle()
Since the change in the list style is performed through a command triggered through the RadRichTextBoxRibbonUI, you can utilize this new list type just by adding a line in the already generated XAML, namely:
This code will create and utilize a list that would look like this:
If you wish to register a new bulleted list, it is even easier. You can choose the characters you wish to appear at each level like in the following snippet:
You can find the source code (a fully-functional example with an extended RibbonGalery) attached to this blog post.
Feedback would be, as always, greatly appreciated.
Iva Toteva is a software developer and works closely with clients to assist them in utilizing the RadControls they use for the purposes of their application. The controls in her domain include RadRichTextBox, RadSpreadsheet and RadPdfViewer.
Copyright © 2016, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.