本文整理汇总了VB.NET中System.Windows.Forms.PaintEventArgs类的典型用法代码示例。如果您正苦于以下问题:VB.NET PaintEventArgs类的具体用法?VB.NET PaintEventArgs怎么用?VB.NET PaintEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PaintEventArgs类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Pen
Dim RcDraw As Rectangle
Dim PenWidth As Integer = 5
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
' Determine the initial rectangle coordinates...
RcDraw.X = e.X
RcDraw.Y = e.Y
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
' Determine the width and height of the rectangle...
If e.X < RcDraw.X Then
RcDraw.Width = RcDraw.X - e.X
RcDraw.X = e.X
Else
RcDraw.Width = e.X - RcDraw.X
End If
If e.Y < RcDraw.Y Then
RcDraw.Height = RcDraw.Y - e.Y
RcDraw.Y = e.Y
Else
RcDraw.Height = e.Y - RcDraw.Y
End If
' Force a repaint of the region occupied by the rectangle...
Me.Invalidate(RcDraw)
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
' Draw the rectangle...
e.Graphics.DrawRectangle(New Pen(Color.Blue, PenWidth), RcDraw)
End Sub
示例2: PictureBox
' This example creates a PictureBox control on the form and draws to it.
' This example assumes that the Form_Load event handler method is connected
' to the Load event of the form.
Private pictureBox1 As New PictureBox()
Private fnt as New Font("Arial", 10)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Dock the PictureBox to the form and set its background to white.
pictureBox1.Dock = DockStyle.Fill
pictureBox1.BackColor = Color.White
' Connect the Paint event of the PictureBox to the event handler method.
AddHandler pictureBox1.Paint, AddressOf Me.pictureBox1_Paint
' Add the PictureBox control to the Form.
Me.Controls.Add(pictureBox1)
End Sub
Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
' Create a local version of the graphics object for the PictureBox.
Dim g As Graphics = e.Graphics
' Draw a string on the PictureBox.
g.DrawString("This is a diagonal line drawn on the control", _
fnt, Brushes.Red, New PointF(30.0F, 30.0F))
' Draw a line in the PictureBox.
g.DrawLine(System.Drawing.Pens.Red, pictureBox1.Left, _
pictureBox1.Top, pictureBox1.Right, pictureBox1.Bottom)
End Sub