I have made my own simple find text dialog, to link with my richtextbox. Currently it works, but every time it only selects the first appearance of the wanted text, and stops there.
I would like it to stay open, and highlight the wanted text from the textbox in the dialog without having to press cancel after OK. (Without the me.close() I have to press OK then Cancel for it to find and highlight the text.
I also want it to find text forward from where the cursor currently is. Like most of Windows Find Dialogs, and make it stay open so you can switch through all the text wanted in the richtextbox.
Basically, I want pretty much a Find Dialog the same as most Windows Programs.
Currently I have this:
Help Please.
P.S. Why doesn't VB have Find Dialogs built in? Or is there an add-in somewhere where I can get this.
I would like it to stay open, and highlight the wanted text from the textbox in the dialog without having to press cancel after OK. (Without the me.close() I have to press OK then Cancel for it to find and highlight the text.
I also want it to find text forward from where the cursor currently is. Like most of Windows Find Dialogs, and make it stay open so you can switch through all the text wanted in the richtextbox.
Basically, I want pretty much a Find Dialog the same as most Windows Programs.
Currently I have this:
VB.NET:
[SIZE=2][COLOR=#0000ff]
Public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] FindDialog
[/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OK_Button_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] OK_Button.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].DialogResult = System.Windows.Forms.DialogResult.OK
[/SIZE][SIZE=2][COLOR=#008000]'If Developer.RichTextBox1.SelectedText Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'End If
[/COLOR][/SIZE][SIZE=2]Developer.RichTextBox1.Find(TextBox1.Text)
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Close()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] Cancel_Button_Click([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] Cancel_Button.Click
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].DialogResult = System.Windows.Forms.DialogResult.Cancel
[/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].Close()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class
[/COLOR][/SIZE]
Help Please.
P.S. Why doesn't VB have Find Dialogs built in? Or is there an add-in somewhere where I can get this.