Results 1 to 3 of 3

Thread: [RESOLVED] Change a text in richtextbox but keep image in it

  1. #1

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Resolved [RESOLVED] Change a text in richtextbox but keep image in it

    I have a richtextbox with images and text.
    I want to change specified text but i want to keep my image.
    How can i do that.
    I use :

    Dim aLines() As String = rtbDisplay.Lines
    aLines(i) = aLines(i).Replace(str, "")
    rtbDisplay.Lines = aLines

    but do not work.
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Change a text in richtextbox but keep image in it

    You can't using Lines I don't think. You'll have to find the text you want to replace, set SelectionStart and SelectionLength, then set SelectedText.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Fanatic Member manhit45's Avatar
    Join Date
    May 2009
    Location
    Ha noi - Viet Nam
    Posts
    826

    Re: Change a text in richtextbox but keep image in it

    OK. THANKS JM.
    I resolved :

    Code:
    Private Sub Hamthaydoidong(ByVal str As String)
            Dim aLines() As String = rtbDisplay.Lines
            If aLines(rtbDisplay.Lines.Length - 2).Contains(str) = True Then
                rtbDisplay.SelectionStart = rtbDisplay.Text.IndexOf(str)
                rtbDisplay.SelectionLength = str.Length
                rtbDisplay.SelectedText = "":duck:
            End If
    
        End Sub
    --***----------***-----

    If i help you please rate me.

    Working with Excel * Working with String * Working with Database * Working with array *

    K51 ĐH BÁCH KHOA HÀ NỘI - Khoa CNTT pro.

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