vb.net 类中 定义了 dim withevents mpc as picturebox 还有picturebox的paint 事件 该怎么使用这个类
PublicClassbbbbDimWithEventsPicCurveAsPictureBoxDimWithEventsPicCurveAsPictureBoxDimx...
Public Class bbbb
Dim WithEvents PicCurve As PictureBox
Dim WithEvents PicCurve As PictureBox
Dim xStep As Single = 5, yStep As Single
Dim ValueArray As ArrayList
Dim ThresHold() As Single 'HIHI、HI、LO、LOLO
Dim Name As String = "参数名"
Dim Unit As String = "单位"
Public Sub New(ByVal mPictureBox As PictureBox, ByVal mThresHold() As Single, ByVal mName As String)
ValueArray = New ArrayList
PicCurve = mPictureBox
ThresHold = mThresHold
mPictureBox.BorderStyle = BorderStyle.None
Name = mName
End Sub
Private Sub PicCurve_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PicCurve.Paint
Call DrawReferenceFrame(e.Graphics)
End Sub
Private Sub PicCurve_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles PicCurve.Resize
On Error Resume Next
xStep = 5
yStep = (PicCurve.Height - 2 * Yoffset) / (ThresHold(0) - ThresHold(3))
End Sub
Private Sub DrawReferenceFrame(ByVal G As Graphics)
……
end sub
end class
在窗体中应该怎么用这个类
调用paint 事件 展开
Dim WithEvents PicCurve As PictureBox
Dim WithEvents PicCurve As PictureBox
Dim xStep As Single = 5, yStep As Single
Dim ValueArray As ArrayList
Dim ThresHold() As Single 'HIHI、HI、LO、LOLO
Dim Name As String = "参数名"
Dim Unit As String = "单位"
Public Sub New(ByVal mPictureBox As PictureBox, ByVal mThresHold() As Single, ByVal mName As String)
ValueArray = New ArrayList
PicCurve = mPictureBox
ThresHold = mThresHold
mPictureBox.BorderStyle = BorderStyle.None
Name = mName
End Sub
Private Sub PicCurve_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PicCurve.Paint
Call DrawReferenceFrame(e.Graphics)
End Sub
Private Sub PicCurve_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles PicCurve.Resize
On Error Resume Next
xStep = 5
yStep = (PicCurve.Height - 2 * Yoffset) / (ThresHold(0) - ThresHold(3))
End Sub
Private Sub DrawReferenceFrame(ByVal G As Graphics)
……
end sub
end class
在窗体中应该怎么用这个类
调用paint 事件 展开
展开全部
大体看一下这个类里的事件都是私有的(Private) 如果想在窗体中使用这个事件就把类中事件前的Private关键字改成Public如:
Public Sub PicCurve_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PicCurve.Paint
在窗体中调用的方法就是实例化类就行了。因为这个类有NEW所以在实例化的时候要赋参数
代码如下数值是我临时写的。调用的时候你根据实际情况改一下就行。参数PictureBox1是在窗体上添加的PictureBox控件。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AA() As Single = {0.1, 1.2, 1.5, 1.6, 1.8}
Dim clsPaint As New bbbb(PictureBox1, AA, "PictureBox_1")
clsPaint.PicCurve_Paint(Me, Nothing)
End Sub
Public Sub PicCurve_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PicCurve.Paint
在窗体中调用的方法就是实例化类就行了。因为这个类有NEW所以在实例化的时候要赋参数
代码如下数值是我临时写的。调用的时候你根据实际情况改一下就行。参数PictureBox1是在窗体上添加的PictureBox控件。
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim AA() As Single = {0.1, 1.2, 1.5, 1.6, 1.8}
Dim clsPaint As New bbbb(PictureBox1, AA, "PictureBox_1")
clsPaint.PicCurve_Paint(Me, Nothing)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询