Results 1 to 2 of 2

Thread: WPF VB Formatting only last selection in Richtextbox using TextRange or TextSelection

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2015
    Posts
    4

    WPF VB Formatting only last selection in Richtextbox using TextRange or TextSelection

    0
    down vote
    favorite


    I'm working in wpf and visual basic. When I select text in RichTextBox i use TextRange:
    Code:
    dim selection1 as New TextRange(Richtextbox.selection.start,Richtextbox.selection.end)
    Later:
    Code:
    selection1.ApplyPropertyValue(ForegroundProperty, brushes.Red)
    When I am marking text many times the color changes also in the previous selections. I want change color only last selection. How to do this?

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    2,020

    Re: WPF VB Formatting only last selection in Richtextbox using TextRange or TextSelec

    The TextRange object has a ClearAllProperties Method.

    TextRange.ClearAllProperties Method

    Just set the TextRange parameters with the correct TextPointer positions.

    Regards,

    - kgc
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal | Programming
    Projects: GitHub | jsFiddle
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width