Discussion:
insert a Page-break in a vb6-Richtextbox
(too old to reply)
Catharinus van der werf
10 years ago
Permalink
Hello my friens

I want to insert a page-break in a richtextbox.

Any idea's?

thanks in advantage

Catharinus van der Werf
Henning
10 years ago
Permalink
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
go down to Josephs reply...

richTextBox1.SelectedRtf = @"{\rtf1 \par \page}";

/Henning
Henning
10 years ago
Permalink
Post by Henning
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
go down to Josephs reply...
/Henning
and the link...
https://social.msdn.microsoft.com/Forums/en-US/902b1cdf-8346-4a79-888c-cd607b1a4ebb/insert-page-break-in-rich-text-box?forum=winforms

/Henning
Catharinus van der werf
10 years ago
Permalink
Thanks Henning

I have seen that link before. But how can I insert this in the rtf?
How can I change the rtfText??

Catharinus
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
Eduardo
10 years ago
Permalink
Post by Catharinus van der werf
Thanks Henning
I have seen that link before. But how can I insert this in the rtf?
How can I change the rtfText??
That code could be used in RTF rendering devices that have pages, but if you
are using a RichTextBox, do you see any page on it?
If the device don't have support for pages, you cannot add pages then.

What are you trying to do?

BTW: that code is for the TextRTF property, not for the Text one.
Catharinus van der werf
10 years ago
Permalink
Post by Eduardo
Post by Catharinus van der werf
Thanks Henning
I have seen that link before. But how can I insert this in the rtf?
How can I change the rtfText??
That code could be used in RTF rendering devices that have pages, but if you
are using a RichTextBox, do you see any page on it?
If the device don't have support for pages, you cannot add pages then.
What are you trying to do?
BTW: that code is for the TextRTF property, not for the Text one.
Thanks Eduardo

I use the richtextbox to show the content of serveral invoices in one time, like a Word-program. But each invoice should begin at a new page. At this moment I simple count the lines and start a new page when the maximum of the page is reached. But this is not accurate, especially because I can also change the fontsize of the richtexbox.

I know that this is for the TextRTF. And that is were it should be incorporated I quess.

Catharinus
Henning
10 years ago
Permalink
Post by Eduardo
Post by Catharinus van der werf
Thanks Henning
I have seen that link before. But how can I insert this in the rtf?
How can I change the rtfText??
That code could be used in RTF rendering devices that have pages, but if you
are using a RichTextBox, do you see any page on it?
If the device don't have support for pages, you cannot add pages then.
What are you trying to do?
BTW: that code is for the TextRTF property, not for the Text one.
Thanks Eduardo

I use the richtextbox to show the content of serveral invoices in one time,
like a Word-program. But each invoice should begin at a new page. At this
moment I simple count the lines and start a new page when the maximum of the
page is reached. But this is not accurate, especially because I can also
change the fontsize of the richtexbox.

I know that this is for the TextRTF. And that is were it should be
incorporated I quess.

Catharinus

Isn't it possible to add ie a RS (ascii &H1E) to separate invoices?

/Henning
Catharinus van der werf
10 years ago
Permalink
You mean inserting that in the TextRTF?
...
I think it should been put in the RTFText as you first suggested
with richTextBox1.selrtf = @"{\rtf1 \par \page}";
But how?
Henning
10 years ago
Permalink
"Catharinus van der werf" <***@gmail.com> skrev i meddelandet news:27e108a6-2a57-4be8-957e-***@googlegroups.com...
You mean inserting that in the TextRTF?
...
I think it should been put in the RTFText as you first suggested
with richTextBox1.selrtf = @"{\rtf1 \par \page}";
But how?

The RS char is supposed to help find the line# of an invoice start and end.
Use Find(string, start, end, options) to get the index of RS, then use
GetLineFromChar(charpos) to get the line#.

/Henning
Catharinus van der werf
10 years ago
Permalink
Hello Henning
I don't understand how I should incorporate that in the TextRTF
could you explain some more?
Thanks
...
Henning
10 years ago
Permalink
Aircode not tested...
In a module: Public Const PageBrk As String = CHR$(&H1E) & VBCrLf

After loading an invoice.
RichTextBox1.TextRTF = RichTextBox1.TextRTF & PageBrk

This I guess will add RS to be serchable, marking the end of invoice.

/Henning


"Catharinus van der werf" <***@gmail.com> skrev i meddelandet news:fb02af95-9b03-42d2-af9c-***@googlegroups.com...
Hello Henning
I don't understand how I should incorporate that in the TextRTF
could you explain some more?
Thanks
...
Eduardo
10 years ago
Permalink
"Catharinus van der werf" <***@gmail.com> escribió en el mensaje
news:df1c0e6b-23ac-4935-b688-
Post by Catharinus van der werf
I use the richtextbox to show the content of serveral invoices in one
time, like a Word-program.
That's the problem, Word has pages, but the RichTextBox does not.
Post by Catharinus van der werf
But each invoice should begin
at a new page.
Again: there are no pages in the RichTextBox
Post by Catharinus van der werf
At this moment I simple count the lines and start a new page when the
maximum of the page is reached. But
this is not accurate,
Do you mean accurate with the printer?
Post by Catharinus van der werf
especially because I can also change the fontsize of the richtextbox.
I'm guessing that you want some space (several new lines) between invoices
and that should match what will be printed when the user prints them (it
should match the physical page changes), and that the program uses some
other routine to send the invoices to the printer.

is that the case?
Catharinus van der werf
10 years ago
Permalink
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
I mean, when inserting it with
richTextBox1.selrtf = @"{\rtf1 \par \page}";
nothing changed in the SelRTF
Eduardo
10 years ago
Permalink
Post by Catharinus van der werf
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
I mean, when inserting it with
nothing changed in the SelRTF
I tested that. I have a routine that prints the content of the richtextbox,
and that code ( "{\rtf1 \par \page}" ) just adds a new line in the RTB.
BTW, the code can be just "\page "

richTextBox1.selrtf = "\page "
Catharinus van der werf
10 years ago
Permalink
Post by Eduardo
Post by Catharinus van der werf
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
Thanks Eduardo
I use the richtextbox to show the document(s) and to prepare the document(s) that I want to print or send to Word or another document.
When more then one document is shown, there should be a clear separation between the documents, for example as you can do in a Word-document with a hard return.
When I manually insert "\par \page" in an rtf file (via a simple tekst-editor),
I see there there is an extra page in the document when I open it with Word for example.
Post by Eduardo
Post by Catharinus van der werf
I mean, when inserting it with
nothing changed in the SelRTF
I tested that. I have a routine that prints the content of the richtextbox,
and that code ( "{\rtf1 \par \page}" ) just adds a new line in the RTB.
BTW, the code can be just "\page "
richTextBox1.selrtf = "\page "
Eduardo
10 years ago
Permalink
"Catharinus van der werf" <***@gmail.com> escribió en el mensaje
news:21cefc61-6f7e-4dd3-8de0-Thanks Eduardo
Post by Catharinus van der werf
I use the richtextbox to show the document(s) and to prepare the
document(s) that I want to print or send to Word or another
document.
When more then one document is shown, there should be a clear separation
between the documents, for example as you can
do in a Word-document with a hard return.
When I manually insert "\par \page" in an rtf file (via a simple tekst-editor),
I see there there is an extra page in the document when I open it with Word for example.
I don't understand what routine you use to send the documents to Word and to
print.

How is it related that to the RichTextBox?

If you just need to show some space between invoices, add some "\par \par
\par \par " to the SelRTF or vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf to
the SelText of the RTB (it is the same).

If you use the rtf code of the control to somewhat to send it to Word (I
don't know how or if it's possible), you'll have to replace the "\par \par
\par \par " with "\page ".

And what about printing? How do you print?

I see it very difficult to do it right if you use different routines for
each case.
Catharinus van der werf
10 years ago
Permalink
Hello Eduardo

In fact it looks like you know how to do it
You told that you were able to insert code
in the rtftext. And that is at this moment
just what I want to know: how did you insert
code in the RTFText. When you have answered that
question, I could proberbly try again myself.
Thanks
Catharinus
...
Eduardo
10 years ago
Permalink
"Catharinus van der werf" <***@gmail.com> escribi� en el mensaje news:264f1b19-2805-4ae5-8080-***@googlegroups.com...
Hello Eduardo
Post by Catharinus van der werf
In fact it looks like you know how to do it
You told that you were able to insert code
in the rtftext.
I don't know what you mean that I said about inserting code.
Post by Catharinus van der werf
And that is at this moment
just what I want to know: how did you insert
code in the RTFText. When you have answered that
question, I could proberbly try again myself.
But, yes, to insert code you can use the .SelRTF property as you already
seem to know.

What I usually do is to prepare all the rtf code in a string variable, and
set it at the end into the .TextRTF property.

For some bug in the RTB (it seems to remember the last font -I guess it's a
bug-) I always set the .Text property to "" before setting the TextRTF.

Then I do something like this:

Dim iRTF as String

iRTF = "Some title\par \par "

For c = 1 to SomeCount
iRTF = iRTF & SomeItem(c) & "\par "
Next c

iRTF = iRTF & "\par Footer text."

RichTextBox1.Text = ""
RichTextBox1.TextRTF = iRTF
Eduardo
10 years ago
Permalink
Post by Eduardo
What I usually do is to prepare all the rtf code in a string variable, and
set it at the end into the .TextRTF property.
But you need to know that if you need to perform some other formatting, it's
not so easy doing it in the rtf code.

When you use the .SelColor, .SelFontName, .SelFontName, .SelBold and all
.Sel* properties, the RTB adds the proper rtf codes for you.

But if you want to do it yourself, you need to learn how to format the rtf
text.

For example:
font bold is "\b some text\b0"
font size is "{\fs24 some text} ' where the number is twice the points of
the font that you want. So fs24 is for font size 12.

Colors are more complicated, because you need to define a color table at the
beginning. The same for font names.

So I suggest to you to mess with the rtf text only if you are going to write
plain text, otherwise it's a bit difficult.
Eduardo
10 years ago
Permalink
Post by Eduardo
So I suggest to you to mess with the rtf text only if you are going to
write plain text, otherwise it's a bit difficult.
I mean plain text with just some simple formatting.
If you are going to write _plain text_ use .Text :-)
Catharinus van der werf
10 years ago
Permalink
Post by Eduardo
Post by Eduardo
So I suggest to you to mess with the rtf text only if you are going to
write plain text, otherwise it's a bit difficult.
I mean plain text with just some simple formatting.
If you are going to write _plain text_ use .Text :-)
Hee Eduardo

thank you very much
I will try your examples and hope
I can insert some code in the RTFText
thanks again
Catharinus
Larry Serflaten
10 years ago
Permalink
Post by Catharinus van der werf
I want to insert a page-break in a richtextbox.
Any idea's?
From the 'any ideas' department....

Have you thought about using multiple RTB controls where each RichTextbox
holds one document? I would think it would be easier to manage the printing
of each document to a page. If you like the one long list for display you
could use the viewport method lining them all up in a scrollable Picturebox.

LFS
Catharinus van der werf
10 years ago
Permalink
Thanks Eduardo
I have tried to insert "\par \page" in the the TextRTF again
again without succes
Only when I insert the tekst in the TextRTF via a simple
texteditor (notepad++) then the Page-break works fine
Catharinus
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
Eduardo
10 years ago
Permalink
Post by Catharinus van der werf
Thanks Eduardo
I have tried to insert "\par \page" in the the TextRTF again
again without succes
Only when I insert the tekst in the TextRTF via a simple
texteditor (notepad++) then the Page-break works fine
The \page tag doesn't work in the RichTextBox control, it only adds another
new line.

When you say a text editor I guess that you are talking about a file that
you later open with Word. Word does support the \page tag.

That's because Word has pages but the RichTextBox control does not have
pages.
Catharinus van der werf
10 years ago
Permalink
Hai Eduardo

It can definitely been added to the rtf-file, via a simple texteditor as notepad or something like that. After doing that, you will see a next page
...
Eduardo
10 years ago
Permalink
"Catharinus van der werf" <***@gmail.com> escribi� en el mensaje news:f1b2b447-c006-4168-9888-***@googlegroups.com...
Hai Eduardo
Post by Catharinus van der werf
It can definitely been added to the rtf-file, via a simple texteditor as
notepad or something like that. After doing that, you will see
a next page
Where do you see the next page?
In the RichTextBox???
Catharinus van der werf
10 years ago
Permalink
Post by Catharinus van der werf
Hai Eduardo
Post by Catharinus van der werf
It can definitely been added to the rtf-file, via a simple texteditor as
notepad or something like that. After doing that, you will see
a next page
Where do you see the next page?
In the RichTextBox???
Open the rtf with notepad and insert the code "\par \page"
and save it
then open it with for example word
Eduardo
10 years ago
Permalink
"Catharinus van der werf" <***@gmail.com> escribió en el mensaje
news:85bdd834-2dfe-4658-8411-
Post by Catharinus van der werf
Open the rtf with notepad and insert the code "\par \page"
and save it
then open it with for example word
It is not "for example".

It is what I'm saying: (pay attention)
Word does support page breaks, but the RichTextBox doesn't support them
because it does not have pages.
The RichTextBox is a single control with no pages.
Catharinus van der werf
10 years ago
Permalink
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
Thanks Henning
but the important part: how to make a page-break in the Richttextbox isn't solved this way. Maybe I should make a page-break in a simple textfile??
Catharinus
Henning
10 years ago
Permalink
Post by Catharinus van der werf
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
Thanks Henning
but the important part: how to make a page-break in the Richttextbox isn't
solved this way. Maybe I should make a page-break in a simple textfile??
Catharinus
What if you change the PageBrk = "RS" to "/page"? You most likely cant see
it in the RTB, but saved and opened in word would show it.

/Henning
Eduardo
10 years ago
Permalink
Post by Henning
"/page"?
"\page "
MikeD
10 years ago
Permalink
Post by Catharinus van der werf
Post by Catharinus van der werf
Hello my friens
I want to insert a page-break in a richtextbox.
Any idea's?
thanks in advantage
Catharinus van der Werf
Thanks Henning
but the important part: how to make a page-break in the Richttextbox isn't
solved this way. Maybe I should make a page-break in a simple textfile??
Catharinus
You certainly can't do a "page break" in a plain text file. Sure, you could
implement CRLFs to fake it, but that would be mostly hit or miss depending
on user's printer and/or page setup and probably a number of other things
that would make the coding difficult to support. Maybe, and just throwing
this out there for consideration, what you really need to do is create a
report using any number of the available reporting options. These options
could include Crystal Reports, SQL Service Reporting Services, or even VB6's
built-in Report Designer. Which one is best depends on your specific
circumstances, knowledge, and experience. There could be other "reporting"
options too. All of them, at least the ones I mentioned and probably most
others, would address your page break issue and probably be better overall
than using an RTB or even RTF in general.

Mike

Loading...