Re: Is it possible to edit the font in a single text box?
- From: "Mike Williams" <Mike@xxxxxxxxxxxxxxxxx>
- Date: Wed, 3 Jan 2007 15:46:07 -0000
"PeterD" <peter2@xxxxxxxxxx> wrote in message news:aaenp2l9q8cs4g0mrim4p3ca7co495bj9d@xxxxxxxxxx
Ideal would be either drop in RTF at design time. Next best would
be go grab a resource string and drop it in at run time, but I hate the
performance hit of initializing frequently which could happen.
What do you mean about "hating the performance hit"? You drop the RTF from your resource into the RichTextBox just once in the Form's Load event. I've just timed the act of doing exactly that job using a typical medium sized rtf file and on my machine the combined total time of loading the rtf data from the resource file and then dropping into an RTB takes about half a millisecond, and that includes the time it takes for the RTB to format the data! Half a millisecond, just once when your Form loads! Besides, even if VB did have a facility for you to insert the rtf at design time it would still need to create the RTB and carry out a similar task itself as the Form loads. There is no performance hit.
All you need to do is create your rtf file (in Microsoft Word perhaps or some other suitable editor) and then use the VB Resource Editor to add that rtf file as a custom resource in your VB resource file. The file's data will be inserted into the resource and will of course be compiled as part of your VB program, and you can use the following simple code to place it into the RichTextBox at run time (assuming the number of the resource is 101):
Private Sub Form_Load()
RichTextBox1.TextRTF = StrConv(LoadResData(101, "CUSTOM"), vbUnicode)
End Sub
Mike
.
- Follow-Ups:
- Re: Is it possible to edit the font in a single text box?
- From: PeterD
- Re: Is it possible to edit the font in a single text box?
- From: Dave O.
- Re: Is it possible to edit the font in a single text box?
- From: Rick Rothstein \(MVP - VB\)
- Re: Is it possible to edit the font in a single text box?
- References:
- Re: Is it possible to edit the font in a single text box?
- From: Mike Williams
- Re: Is it possible to edit the font in a single text box?
- From: PeterD
- Re: Is it possible to edit the font in a single text box?
- From: Rick Rothstein \(MVP - VB\)
- Re: Is it possible to edit the font in a single text box?
- From: PeterD
- Re: Is it possible to edit the font in a single text box?
- Prev by Date: Re: Setting the values of UDTs
- Next by Date: Re: output parameters
- Previous by thread: Re: Is it possible to edit the font in a single text box?
- Next by thread: Re: Is it possible to edit the font in a single text box?
- Index(es):
Relevant Pages
|