Disabling Wordwrap in RichTextbox

J

Jay Ayliff

I've tried everything I can think of to disable wordwrap. Here's the code
that sets up my RichTextbox rtfSQL:

With rtfSQL
.AcceptsTab = True ' Tab is a valid character, not a command to go to
next control
.RightMargin = .MaxLength ' Stop wordwrap
.WordWrap = False ' Stop wordwrap
.ScrollBars = RichTextBoxScrollBars.Both
.Multiline = True
End With

..but it still wordwraps! I want there to be horizontal and vertifal
scrollbars and no wordwrap. I could have sworn it worked yesterday. This is
so annoying! What am I doing wrong?
Regards
Jay Ayliff
Stalis Ltd
 
M

Morten Wennevik

Hi Jay,

The problem is RichTextBox.RightMargin
For some reason it can't deal with the largest integers, like RichTextBox.MaxLength.

Try setting the RightMargin to any other large value up to about MaxLength / 15.
I suspect this is linked to the size of the font as RightMargin accepts pixels and MaxLength is number of Characters.
 
J

Jay Ayliff

Hi Morten,

Thanks for the advice. Yes, that worked, though one wonders why it didn't
throw me a trappable error if it wasn't going to work.

Jay Ayliff


Morten Wennevik said:
Hi Jay,

The problem is RichTextBox.RightMargin
For some reason it can't deal with the largest integers, like RichTextBox.MaxLength.

Try setting the RightMargin to any other large value up to about MaxLength / 15.
I suspect this is linked to the size of the font as RightMargin accepts
pixels and MaxLength is number of Characters.
 

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

Similar Threads


Top