two fairly easy ones (hopefully!):
I want to change the text color in a rich text box any idea?
And:
For some reason the tab button makes the cursor disapear out of my rich text box, know how to fix this?
Anybody have any ideas?
Printable View
two fairly easy ones (hopefully!):
I want to change the text color in a rich text box any idea?
And:
For some reason the tab button makes the cursor disapear out of my rich text box, know how to fix this?
Anybody have any ideas?
Question 1
http://forums.vb-world.net/showthrea...threadid=32197
Question 2
Code:'You can set the Tabstop property to false for all the controls:
'disable the tab form
Private Sub Form_Load()
Dim i As Integer
On Error Resume Next
For i = 0 To Controls.Count - 1 ' Use the Controls collection
Controls(i).TabStop = False
Next
End Sub
1. Set the SelColor property to what ever you want.
2. To enable the tab as a tab key, so that is does not tab to the next control, you need to set all of the other controls TabStop property to false.Code:rtxt.SelColor = vbRed
You do that in the Got_Focus event. Then set them back to true in the lost_focus event.
Code:Dim myControl as Control
For Each myControl In Controls
myControl.TabStop = False
Next
To Set Color, find the text and change the color:
Code:Private Sub Find_Text(strFindText As String)
Dim FoundPos As Integer
'Find the text specified in the strFindText Parameter.
FoundPos = RichTextBox1.Find(strFindText, , , rtfWholeWord)
'If found then change the color.
If FoundPos <> -1 Then
'Set Color of found text to Red
RichTextBox1.SelColor = vbRed
End If
End Sub
Disable TabStop for Controls When Entering A RichText Box
so pressing the tab key doesn't cause the focus to be set
to the next control in the tabindex order.
Make sure you Re-Enable TabStop for Controls When LeavingCode:Private Sub RichTextBox1_GotFocus()
Dim Control As Control
'Ignore errors for controls without the TabStop property.
On Error Resume Next
'Switch off the change of focus when pressing TAB.
For Each Control In Controls
Control.TabStop = False
Next Control
End Sub
the RichText Box so pressing the tab key does set focus
to the next control.
-- HeSaidJoe and Iain are must be faster typers than me.Code:Private Sub RichTextBox1_LostFocus()
Dim Control As Control
'Ignore errors for controls without the TabStop property.
On Error Resume Next
'Switch off the change of focus when pressing TAB.
For Each Control In Controls
Control.TabStop = True
Next Control
End Sub
There weren't any posts when I started this. :)
jcouture100
On my part, no typing...searchable mdb :D Cut 'n Paste
Private1 posted a thread wanting to copy 1 line of a RTB (by clicking a button) to another RTB maintaining font,
color, underline, etc, etc. The second RTB should have a CrLf after each entry, i.e.
each line typed into RTB1 should be on a separate line in RTB2. I'm not to keen on RTBs and
I've been grappling with this all day.
I can get the RTB1 lines to print in the correct format (colors, etc) but can't seem to
get them on separate lines.
Any advice?
[Edited by dsy5 on 09-24-2000 at 07:58 PM]
I really would suggest you post this question in a new
thread to get more responses. I doubt the guru's out there
will be reading a post that already has 5 other posts on it.
But with that in mind, I guess I really don't understand the
problem. I haven't had any problem adding carriage returns
in RichTextBoxes. I threw together a little chat type
window and put the contents of one RTB into another with
a leading vbCrLf without any problems. Here is the code I
used...
Hope this helps.Code:'Add text from RTB2 to end of RTB1. Separate with
'a Carriage Return.
rtb1.Text = rtb1.Text & vbCrLf & rtb2.Text
'Clear RTB2
rtb2.Text = ""
'Set focus back to RTB2
rtb2.SelStart = 0
rtb2.SetFocus
jcouture100
The problem wasn't adding a CrLf, but keeping the copied text with the same formatting (color, etc).
All on separate lines.
It's not really my problem, but trying to help out Private1 I found I could not do it. I'm not very familiar with RTBs, so I will try what you posted.
If you're interested, I will post Private1's code that I was attempting to help him with.
(I believe he copied it from a demo from here or Vb Square).