Print a RTF box from my application - How to do that?

Mefyrx

New member
Joined
Apr 4, 2011
Messages
4
Programming Experience
1-3
I have followed

How to print the content of a RichTextBox control by using Visual Basic .NET or Visual Basic 2005

Altough i wanna keep the class in my program....not creat a dll

So i have made a class called RichTextBoxPrintCtrl.vb


Now i assume that the dll gives the .print to a RTFbox ....

because when i try to use:

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Print the content of the RichTextBox. Store the last character printed.
checkPrint = RichTextBoxPrintCtrl1.Print(checkPrint, RichTextBoxPrintCtrl1.TextLength, e)

' Look for more pages
If checkPrint < RichTextBoxPrintCtrl1.TextLength Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub


It says that the print is not a member to etc rtfbox...

So how would i do that?

Because if i try

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim RTF_Print As New RichTextBoxPrintCtrl.RichTextBoxPrintCtrl
' Print the content of the RichTextBox. Store the last character printed.
checkPrint = RTF_Print.print(checkPrint, RTB_Solution.TextLength, e)
' Look for more pages
If checkPrint < RTB_Solution.TextLength Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
End Sub

as expected, it prints white page ....since it becomes a loop...
how would i say
checkPrint = RTB_Solution.RichTextBoxPrintCtrl.RichTextBoxPrintCtrl.print(checkPrint, RTB_Solution.TextLength, e)
if you know what i mean

Thanks!
 
The download for that article contains both the custom RichTextBoxEx control and a sample usage application, you should check those out.
 
Well i saw the code over there...

It shows you how to create a class (never worked with class so i don't know what it is but i'm following the instruction).....after creating the class, you build the solution and make the dll... well i don't want to do that... i want the class to stay in my main project...
So i have my class having all the code over there wit h the same name....

Now, in the example, it shows how to use the RTF....

The problem is that it says my RTFBOX.PRINT ....witch DOES NOT exist...the .PRINT doesn't exist for a ritchtextbox....

Why, i assume, it is because i haven't create the DLL with the Class and attach that DLL to my software..... because in the code theres a function print.....

So how do i make it work not using a dll but having the class form in my software...that is basicly the question

Thank you
 
Ok, i've learn what Inherits is by searching...so the RichTextBoxPrintCtrl = a richtextbox plus all the items in the class...
So creating an object that is a ritchtextbox, i can now take my real RTF and put it in the new object that contains all the additional functions...
The problem is that .text doesn't seem to include my pictures...

I'm gonna try searching for a solution about that

Dim RTF_Print As New RichTextBoxPrintCtrl.RichTextBoxPrintCtrl
RTF_Print.Text = RTB_Solution.Text
' Print the content of the RichTextBox. Store the last character printed.
checkPrint = RTF_Print.Print(checkPrint, RTB_Solution.TextLength, e)
' Look for more pages
If checkPrint < RTB_Solution.TextLength Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If
 
The point is, which the sample shows, that you add the provided RichTextBoxEx class to your solution (Add Existing). Rebuild and the 'RTB'Ex controls shows up in Toolbox, then you add that control to your form and use that instead of the default RTB control.
 
Back
Top