Mansi Shah Posted January 5, 2009 Posted January 5, 2009 (edited) Hi, I have one panel, on that there is one picturebox. Here I m providing my sample code, in this it is not printing the transparent rich textboxes. Form has 1 printpreviewDialog and 1 printpreviewdocument. Public Class Print Private Sub Print_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim img As Image img = Image.FromFile("c:\sunset.jpg") Dim bm As New Bitmap(img, Panel1.Width, Panel1.Height + 50) PictureBox1.Image = bm PictureBox1.Height = PictureBox1.Image.Height PictureBox1.Width = PictureBox1.Image.Width PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage If PictureBox1.Image.Height > Panel1.Height Then Panel1.AutoScroll = True End If Dim rtb As New TransparentRichTextBox rtb.Text = "Rich Text Box" rtb.Font = New Font("Verdana", 15, FontStyle.Bold) rtb.Size = New Size(500, 100) rtb.Location = New Point(100, 100) rtb.Visible = True PictureBox1.Controls.Add(rtb) PrintDocument1.DefaultPageSettings.Landscape = True Dim btn As New Button btn.Text = "New Button" PictureBox1.Controls.Add(btn) btn.Location = New Point(50, 50) PrintPreviewDialog1.Document = PrintDocument1 PrintPreviewDialog1.ShowDialog() End Sub Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage Dim Bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height) Dim rect As Rectangle = New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height) PictureBox1.DrawToBitmap(Bmp, New Rectangle(0, 0, Bmp.Width, Bmp.Height)) Dim VScrollBarWidth As Integer = 0 Dim HScrollBarHeight As Integer = 0 Dim TaskBarHeight As Integer = 0 e.Graphics.DrawImage(Bmp, 0, 0, Bmp.Width - VScrollBarWidth, Bmp.Height - HScrollBarHeight - TaskBarHeight) End Sub End Class Class TransparentRichTextBox Inherits RichTextBox Public Sub New() MyBase.ScrollBars = RichTextBoxScrollBars.None MyBase.BorderStyle = Windows.Forms.BorderStyle.None End Sub Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams cp.ExStyle = cp.ExStyle Or &H20 Return cp End Get End Property Protected Overloads Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs) End Sub End Class It is showing all the controls in picturebox, but not showing rich text box. why? Edited January 5, 2009 by PlausiblyDamp Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.