ChangeListStyle changes spacing

4 posts, 0 answers
  1. Elijah
    Elijah avatar
    2 posts
    Member since:
    Aug 2014

    Posted 25 Aug 2014 Link to this post

    I have a RTB setup to contain free form text users enter.  I'm using the RichTextProvider.  They have some of the basic font controls from the sample available such as Bold, Italic, Underline, colors, etc.  They are also able to do Bullet and Number lists.

    When changing the list style to the appropriate type, it changes the spacing as well.  In the attached image, you can see where I:
    1) Type "This is a test."
    2) Hit enter
    3) Type "This is a new line."
    4) Hit enter
    5) Click the 'Bullet list' button which initiates a ChangeListStyle with DefaultListStyles.Bulleted
    6) Type "Bullet clicked"
    7) Hit enter
    8) Type "New line in bullet list"
    9) Hit enter
    10) Click the 'bullet list' button which initiates a ChangeListStyle with DefaultListStyles.None
    11) Type "Out of bullet"

    As you can see, the bullet spacing is not the same as the lines before or after.

    How can I keep the spacing the same?
  2. Dess
    Admin
    Dess avatar
    1608 posts

    Posted 28 Aug 2014 Link to this post

    Hello Elijah,

    Thank you for writing.

    You can modify the paragraph line spacing when the DefaultListStyles.Bulleted is applied to display the line spacing equal between normal and bullet rows:
    private void radToggleButton1_ToggleStateChanged(object sender, StateChangedEventArgs args)
    {
        ListStyle style = DefaultListStyles.None;
        float spacing = 0f;
        if (args.ToggleState == ToggleState.On)
        {
            style = DefaultListStyles.Bulleted;
            spacing = 1.0f;
        }
        else
        {
            spacing = 1.15f;
        }
         
        this.radRichTextBox1.DocumentView.ChangeParagraphLineSpacing(spacing);          
        this.radRichTextBox1.ChangeListStyle(style);
    }

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Elijah
    Elijah avatar
    2 posts
    Member since:
    Aug 2014

    Posted 02 Oct 2014 in reply to Dess Link to this post

    This worked, thank you.  I do have another question however.  Is there a way to enforce the spacing for the entire document?  Say I wanted to keep the before and after spacing at .8.  That's when loading content, the user is adding content, hitting enter, bullets, etc.

    Is there a way to do that?  Right  now I'm running into some really funky formatting issues.
  5. Dess
    Admin
    Dess avatar
    1608 posts

    Posted 07 Oct 2014 Link to this post

    Hello Elijah,

    Thank you for writing back.

    You can affect the spacing for the entire document via selecting the whole document content and calling the ChangeParagraphLineSpacing method passing the desired spacing as a parameter:
    radRichTextBox1.Document.Selection.SelectAll();
    radRichTextBox1.ChangeParagraphLineSpacing(2);
    radRichTextBox1.Document.Selection.Clear();

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Desislava
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top