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 事件
展开
 我来答
丢了颜色的海
2011-03-12 · 超过14用户采纳过TA的回答
知道答主
回答量:45
采纳率:0%
帮助的人:0
展开全部
大体看一下这个类里的事件都是私有的(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
whyhlin
2011-02-22
知道答主
回答量:23
采纳率:0%
帮助的人:20.9万
展开全部
with Event表示这是一个接受事件的控件,就像按钮有Click事件一样。一般是编程接受一些特殊的事件,像Click事件什么的都是标准事件,无需编程。特殊事件编程用得不多,我也不太清楚,可以去MSDN查一下,我记得上面有比较完整的关于Withevents的例子。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式