vb.net 类中 定义了 dim withevents mpc as picturebox 还有picturebox的paint 事件 该怎么使用这个类

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 事件

大体看一下这个类里的事件都是私有的(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
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-02-22
with Event表示这是一个接受事件的控件,就像按钮有Click事件一样。一般是编程接受一些特殊的事件,像Click事件什么的都是标准事件,无需编程。特殊事件编程用得不多,我也不太清楚,可以去MSDN查一下,我记得上面有比较完整的关于Withevents的例子。

...类中 定义了 dim withevents mpc as picturebox 还有picturebox的pai...
Public Sub PicCurve_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PicCurve.Paint 在窗体中调用的方法就是实例化类就行了。因为这个类有NEW所以在实例化的时候要赋参数 代码如下数值是我临时写的。调用的时候你根据实际情况改一下就行。参数PictureBox1是...

请问VB编程:Dim WithEvents mFrm As FrmRepairItem中 WithEvents是什么...
WithEvents是可以有事件支持 FrmRepairItem是某种对象,mFrm是FrmRepairItem类型的对象,不是变量 如同下面:dim 楼主 as 有良心的中国人

VB 创建透明窗体
透明位图在VB中的实现方法及应用 在VB中显示位图,通常都是通过各种控件实现的。通过控件显示的位图,或全部或局部,始终是以一个规则的矩形图像出现在屏幕上,无法做到只显示位图中某个不规则的局部图像,而使位图的其它部分具有透明性以露出其下原有的屏幕显示,即所谓“透明位图”,因此透明位图的实现只能...

相似回答
大家正在搜