Torna al Thread

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click PrintPreviewDialog1.Document = pdMod PrintPreviewDialog1.ShowDialog() End Sub Private Sub Mod_01() Dim wid As Integer = PictureBox1.ClientSize.Width Dim hgt As Integer = PictureBox1.ClientSize.Height ' Do nothing if we have no size. ' This happens, for example, if the form is minimized. If wid < 1 Or hgt < 1 Then Exit Sub ' Make a Bitmap and Graphics to fit. Dim bm As New Bitmap(wid, hgt) Dim gr As Graphics = Graphics.FromImage(bm) Dim bg_brush As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.DarkHorizontal, _ Color.Blue, Color.Aqua) gr.FillRectangle(bg_brush, PictureBox1.ClientRectangle) ' Display the result. PictureBox1.Image = bm ' Free resources. bg_brush.Dispose() gr.Dispose() End Sub Private Sub Mod_02() Dim wid As Integer = PictureBox1.ClientSize.Width Dim hgt As Integer = PictureBox1.ClientSize.Height ' Do nothing if we have no size. ' This happens, for example, if the form is minimized. If wid < 1 Or hgt < 1 Then Exit Sub ' Make a Bitmap and Graphics to fit. Dim bm As New Bitmap(wid, hgt) Dim gr As Graphics = Graphics.FromImage(bm) Dim bg_brush As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.DarkVertical, _ Color.Blue, Color.Aqua) gr.FillRectangle(bg_brush, PictureBox1.ClientRectangle) ' Display the result. PictureBox1.Image = bm ' Free resources. bg_brush.Dispose() gr.Dispose() End Sub Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged 'Me.PictureBox1.Image = Nothing Select Case Me.ListBox1.SelectedIndex Case 0 Mod_01() Case 1 Mod_02() End Select End Sub Private Sub pdMod_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles pdMod.PrintPage Dim wid As Integer = PictureBox1.ClientSize.Width Dim hgt As Integer = PictureBox1.ClientSize.Height ' Do nothing if we have no size. ' This happens, for example, if the form is minimized. If wid < 1 Or hgt < 1 Then Exit Sub ' Make a Bitmap and Graphics to fit. Dim gr As Graphics = e.Graphics Select Case Me.ListBox1.SelectedIndex Case 0 Dim bg_brush As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.DarkHorizontal, _ Color.Blue, Color.Aqua) gr.FillRectangle(bg_brush, PictureBox1.ClientRectangle) Case 1 Dim bg_brush As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.DarkVertical, _ Color.Blue, Color.Aqua) gr.FillRectangle(bg_brush, PictureBox1.ClientRectangle) End Select gr.Dispose() End Sub
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5