can anyone help me please..
i'm stuck with this thing for 2 days.. i have try to find answer from one forum to another, and it is give me heavy headache.
what i want is that my panel size in my form has a function as print area, in my panel i have one picture box, some txtLabels and some textboxes.
i have try some codes people show, but when i preview it in previewDialog, my preview give me layout more bigger than my panel (i have prove it with add 1 text in each corner of my panel and previewdialog layout show bigger than my panel)
here is the picture :
and here is the code i use (note: this code just for print text, i want include picture box too) :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 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 For Each ctrl As Control In Me.Panel1.Controls Dim sf As New System.Drawing.StringFormat If TypeOf ctrl Is TextBox Then If DirectCast(ctrl, TextBox).TextAlign = HorizontalAlignment.Right Then sf.Alignment = StringAlignment.Far Else sf.Alignment = StringAlignment.Near End If ElseIf TypeOf ctrl Is Label Then If DirectCast(ctrl, Label).TextAlign = HorizontalAlignment.Right Then sf.Alignment = StringAlignment.Far Else sf.Alignment = StringAlignment.Near End If End If e.Graphics.DrawString(ctrl.Text, ctrl.Font, New SolidBrush(ctrl.ForeColor), New RectangleF(ctrl.Left, ctrl.Top + 15, ctrl.Width, ctrl.Height), sf) Next End Sub
i'll do appreciate if you can help me guys, thanks in advance..
Edited 4 Years Ago by artemix22: n/a