lebans rtf2 - can't set font properties

G

greg

I have been using Lebans RTF2 control and am trying to build a spell
checker which on it. I have been trying for some hours and by now I'm
sure I'm doing things correctly.
I try to set the 'baldness' of the selected text in the control by
doing the following:

RTF2control.SelFontBold = False

This didn't work, after trying a few different things I tested:

Debug.Assert rtf2control.SelFontBold=False 'this line placed
immediately after the assignment.

The assertion failed.

It seems strange that immediately after setting the property, it has
changed.

-Greg
 
S

Stephen Lebans

Have you set the SelStart and SelLength props before calling SelFontBold?
You have to select the text you want to apply the formatting to.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

greg

Yes, the text is selected, and the selection is valid:

RTF27.SelStart = 5
RTF27.SelLength = 7
RTF27.SelFontBold = fontBold
Debug.Assert RTF27.SelFontBold = fontBold

I have also printed the values of both fontBold and rtf27.selfontbold
and they are different...
 
G

greg

I think I've tried everything. By now I have determined that whenever
I try to set the selFontBold property, it is set to true.

ie after i use either of these lines:
rtf.SelFontBold=True
rtf.SelFontBold=False

the selected text is made bold.
 
S

Stephen Lebans

Hmmm, it could be a bug in the code but If I remember correctly, the
expected behaviour is as follows:
Whenever you set this property it sets the selected text to Bold if it is
current NOT bold and conversely sets the selected text to plain if it is
currently Bold.

Since that is the standard behaviour of the control, I think the error is
more in my wording of the Property name. The return value is always true to
show success fo the applciation of the formatting. I believe I had the very
same reaction as you to this behaviour when I was originally debugging the
code during the creation fo the RTF2 control.

Does that make sense to you?
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 
G

greg

Ahh.. it's a toggle.

The following worked:

If fontBold = True Then
RTF27.SelFontBold
End If

Thanks for the solution!
 
S

Stephen Lebans

No problem. I have always meant to go back and write a help file for the
control but never find the time.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top