'draw the form image on the printer graphics sized and centered to marginsĭim ratio As Single = CSng(bmp.Width / bmp.Height) Me.DrawToBitmap(bmp, New Rectangle(0, 0, Me.Width, Me.Height)) Using bmp As Bitmap = New Bitmap(Me.Width, Me.Height) 'create a memory bitmap and size to the form Private Sub OnPrintPage(ByVal sender As Object, ByVal e As ) Pd.DefaultPageSettings.PaperSize = New PaperSize("A3", 1169, 1654)ĪddHandler pd.PrintPage, AddressOf OnPrintPage Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.LoadīackgroundImage = Image.FromFile("c:\bitmaps\rusty.jpg")ĭim pd As New Public Sub DrawRectangleRectangle(ByVal e As PaintEventArgs)ĭim rect As New Rectangle(0, 0, 200, 200)Code: 'prints form fit to page and centered with preview set page size to a3 Rectangle rect = new Rectangle(0, 0, 200, 200) Į.Graphics.DrawRectangle(blackPen, rect) Public void DrawRectangleRectangle(PaintEventArgs e) Void DrawRectangleRectangle( PaintEventArgs^ e )Į->Graphics->DrawRectangle( blackPen, rect ) Public Sub DrawRectangleInt(ByVal e As PaintEventArgs) Public void DrawRectangleInt(PaintEventArgs e) Void DrawRectangleInt( PaintEventArgs^ e ) Public Sub DrawRectangleFloat(ByVal e As PaintEventArgs)Į.Graphics.DrawRectangle(blackPen, x, y, width, height)įor information about how to draw a RectangleF, see DrawRectangles(Pen, RectangleF). Public void DrawRectangleFloat(PaintEventArgs e)Į.Graphics.DrawRectangle(blackPen, x, y, width, height) Create location and size of rectangle.Į->Graphics->DrawRectangle( blackPen, x, y, width, height ) Pen^ blackPen = gcnew Pen( Color::Black,3.0f ) Void DrawRectangleFloat( PaintEventArgs^ e ) The code performs the following actions:Ĭreates the position and size of a rectangle. The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |