leo2012 Posted August 18, 2012 at 12:36 AM Report Share #472714 Posted August 18, 2012 at 12:36 AM Alguem pode me dizer como encontro no richtextbox,a palavra que for digitada no textbox,e ainda destacar ela? Procurei muito,oque encontrei foi um exemplo em Visual Basic,e eu preciso em Vb.Net, http://www.macoratti.net/vb_rtb2.htm é exatamente isso que eu quero,mas em vb.net Link to comment Share on other sites More sharing options...
jlpcalado Posted August 18, 2012 at 11:04 AM Report Share #472729 Posted August 18, 2012 at 11:04 AM (edited) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim index As Integer = 0 Dim lastIndex As Integer = RichTextBox1.Find(TextBox1.Text, RichTextBoxFinds.Reverse) While index < lastIndex index = RichTextBox1.Find(TextBox1.Text, index, RichTextBoxFinds.None) RichTextBox1.SelectionBackColor = Color.Yellow RichTextBox1.SelectionColor = Color.Red index += 1 End While End Sub Edited August 20, 2012 at 08:02 AM by Caça Link to comment Share on other sites More sharing options...
leo2012 Posted August 18, 2012 at 09:47 PM Author Report Share #472782 Posted August 18, 2012 at 09:47 PM Muito bom 👍 Mas ele vai mudar a fonte e o back de cada letra,depois se eu for desfazer tenho que ficar pressionando undo ate que todas as letras ou palavras coloridas voltem ao normal,tem como desfazer essa coloração das palavras todas de uma vez so? tipo,um botao,que dê undo somente na função colorir Link to comment Share on other sites More sharing options...
jlpcalado Posted August 18, 2012 at 11:36 PM Report Share #472795 Posted August 18, 2012 at 11:36 PM (edited) Hello. Com a richtextbox do windows.forms um método simples para isso é guardar o texto num ficheiro. O 'undo' equivale a carregar a richtb a partir do ficheiro. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim index As Integer = 0 Dim lastIndex As Integer = RichTextBox1.Find(TextBox1.Text, RichTextBoxFinds.Reverse) 'criar ficheiro na pasta do utilizador RichTextBox1.SaveFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) & "\TesteRich.rtf", RichTextBoxStreamType.RichNoOleObjs) While index <= lastIndex index = RichTextBox1.Find(TextBox1.Text, index, RichTextBoxFinds.None) RichTextBox1.SelectionBackColor = Color.Yellow RichTextBox1.SelectionColor = Color.Red index += 1 End While End Sub 'Repor situação anterior Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Try RichTextBox1.LoadFile(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) & "\TesteRich.rtf", RichTextBoxStreamType.RichText) Kill(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal) & "\TesteRich.rtf") Catch ex As Exception MsgBox("Ficheiro de carregamento não encontrado!") End Try End Sub Edited August 20, 2012 at 08:02 AM by Caça Link to comment Share on other sites More sharing options...
leo2012 Posted August 19, 2012 at 01:12 AM Author Report Share #472805 Posted August 19, 2012 at 01:12 AM obrigado Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now