none
Create RichTextBoxPrintCtrl.dll in VB.NET 2012 RRS feed

  • Question

  • Hi,

    I am using support.MS.com/ kb/811401 (How to print the content of a RichTextBox control by using Visual Basic .NET or Visual Basic 2005 ) to create the RichTextBoxPrintCtrl.dll in VB.NET 2012 using VS2013. Instructions 3 and 4 to add a reference is different in VB 2012, so I used "My Project - References - Add" to add the reference to the dll. Build was executed without errors and the dll is were one would expect it to be.

    But the dll did not showed up in .NET Framework Components and thus not in the toolbox, making it impossible to drag the control on the Form.

    Can some one please give a hint what I should do to solve this problem, or refer me to a trusted site to download the .dll

    With regards

    GerritV2

    Monday, July 13, 2015 12:42 PM

Answers

  • Hi GerritV2,

    Please try to create a new Class Library project named RichTextBoxPrintCtrl(File->New Project->Class Library), in the name column, input RichTextBoxPrintCtrl and click OK.

    After build the RichTextBoxPrintCtrl.vb, you could find the RichTextBoxPrintCtrl.dll in your solution path\RichTextBoxPrintCtrl\bin\Debug. 

    You could only right click the windows application->Add Reference->Browse, click to select RichTextBoxPrintCtrl.dll, and then click OK.  I am afraid that you miss this step.

    On the Tools menu, right click Choose Items.

    After above steps, then click .NET Framework Components, click Browse, click to select RichTextBoxPrintCtrl.dll, and then click OK.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    • Edited by Kristin Xie Tuesday, July 14, 2015 7:31 AM
    • Marked as answer by GerritV2 Wednesday, July 15, 2015 1:30 PM
    Tuesday, July 14, 2015 7:28 AM

All replies

  • Hi GerritV2,

    Please try to create a new Class Library project named RichTextBoxPrintCtrl(File->New Project->Class Library), in the name column, input RichTextBoxPrintCtrl and click OK.

    After build the RichTextBoxPrintCtrl.vb, you could find the RichTextBoxPrintCtrl.dll in your solution path\RichTextBoxPrintCtrl\bin\Debug. 

    You could only right click the windows application->Add Reference->Browse, click to select RichTextBoxPrintCtrl.dll, and then click OK.  I am afraid that you miss this step.

    On the Tools menu, right click Choose Items.

    After above steps, then click .NET Framework Components, click Browse, click to select RichTextBoxPrintCtrl.dll, and then click OK.

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.




    • Edited by Kristin Xie Tuesday, July 14, 2015 7:31 AM
    • Marked as answer by GerritV2 Wednesday, July 15, 2015 1:30 PM
    Tuesday, July 14, 2015 7:28 AM
  • Hi Kristin,

    many thanks for your suggestion; it works.

    But when I Preview some text in the RTBPCtrl or Print some text (one form, RTBPCtl, Print, Preview , PageSetUp and a btn to set the font in the RTBPCtrl) the text is shown twice with different fonts and margins, even though I have set them.

    I would be gratefull when you have a suggestion how to correct this.

    Regards,               GerritV2

    Imports System
    Imports System.Drawing
    Imports System.IO
    Imports System.Drawing.Printing
    Imports System.Windows.Forms
    
    Public Class Form1
        Private checkPrint As Integer
    
        Private Sub PrintDocument1_BeginPrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles PrintDocument1.BeginPrint
            checkPrint = 0
        End Sub
    
        Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    
            Dim font1 As New Font("Courier New", 10, FontStyle.Regular)
            e.Graphics.DrawString(RichTextBoxPrintCtrl1.Text, font1, Brushes.Black, 0, 0)
    
            ' 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
    
        Private Sub btnPageSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPageSetup.Click
    
            PageSetupDialog1.PageSettings = PrintDocument1.DefaultPageSettings
            If PageSetupDialog1.ShowDialog() = DialogResult.OK Then
                PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings
            End If
        End Sub
    
        Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
            If PrintDialog1.ShowDialog() = DialogResult.OK Then
                PrintDocument1.Print()
            End If
        End Sub
    
        Private Sub btnPrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrintPreview.Click
            PrintPreviewDialog1.ShowDialog()
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
     
            RichTextBoxPrintCtrl1.Font = New Font("Courier New", 10, FontStyle.Regular)
    
        End Sub
    End Class
    

    Wednesday, July 15, 2015 1:58 PM