|
-
Feb 12th, 2005, 01:21 PM
#5
Re: Help with Rich Text Boxes
Hi,
The RichTextBox (RTB) uses the property .Text to set strings and .RTF to set formatted text. Both of these apply to the entire RTB. IF you want to just apply to selected text, use the .SelectedText and .SelectedRTF properties instead.
If you can actually get hold of the formatted text, from another RTB for example, then you can set it using these.
Changing the formatting of text that is already in the RTB is a different kettle of fish (KOF ). There used to be handy VB6 properties to deal with formatting called SelBold, SelItalic etc. These have all been done away with in favour of the Font (or SelectionFont) object, and it is one of the most irritating changes in the world.
The Font object has a variety of properties, .Bold etc, but they're all readonly. The only thing that is not readonly is the object itself. The way to change font attributes is to set the Font (or Selectionfont) object to be the same as another font object. This you can do by getting it from somewhere else, eg as fret has done from a dialog, or by dimensioning a new one:
Dim newfont1 as New font("Times New Roman", "12", 5)
RTB1.selectionfont = newfont1
Here, the font properties are Font([Name], [Size], [style]), but there are a variety of different combinations you can use. You'll see if you try it, or look up Font object in the help.
So you might want, for example:
Writestuff("Hello World")
RTB1.selectionstart = 6
RTB1.selectionlength = 5
[there are other ways to select a portion of text in an RTB]
Dim newfont1 as New font("Times New Roman", "12", 5)
RTB1.selectionfont = newfont1
HTH
zaza
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|