[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How can search for user selected text within a rich text box using a button?

Posted on 2005-05-04
2
Medium Priority
?
170 Views
Last Modified: 2010-04-23
I am trying to search for text from a rich text box that has already typed in another regular text box by pressing a button.  

RichTextBox1.Find(textbox1.text???)

I am trying alot but nothing seems to work.

Any suggestions?
0
Comment
Question by:sonicamps
2 Comments
 

Author Comment

by:sonicamps
ID: 13933104
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

RichTextBox1.Find(textbox1.text??)
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 13933271
You've almost got it...you have to give the RTB focus to see the highlighted text:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pos As Integer = RichTextBox1.Find(TextBox1.Text)
        If pos <> -1 Then
            RichTextBox1.Focus()
        End If
    End Sub

OR...set the HideSelection() property of the RTB to false and your code will work.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 22 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question