大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
变量值的改变本身就是你程序控制的,也就是说它的变化完全是在你掌控中的,做变量值改变的触发事件实在没有价值。
创新互联建站成都企业网站建设服务,提供网站设计制作、网站建设网站开发,网站定制,建网站,网站搭建,网站设计,响应式网站建设,网页设计师打造企业风格网站,提供周到的售前咨询和贴心的售后服务。欢迎咨询做网站需要多少钱:028-86922220
通常编程者关心的应该是用户操作的控件值发生变化,但这些控件的事件通常都是定义好的,且已经定义的非常全了。
猜测搂主其实是想学习自己制作控件,那就高深了,很多底层的事件通常都是从基本控件中获得的!
Imports System.Text
Imports System.Windows
Imports System.Windows.Forms
Public Class Netin '类 名
'Inherits Forms.Form
Public Shared Netin As New Form
Public components As ComponentModel.IContainer
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
DebuggerStepThrough()
Public Sub InitializeComponent()
Me.components = New ComponentModel.Container()
Dim resources As ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(bjt))
Me.TextBox1 = New TextBox(Me.components)
Me.Button1 = New Button(Me.components)
'For … Next
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Button1)
Me.m = New ContextMenuStrip(Me.components)
Me.m1.Text = "菜单项1"
'设置并添加相关控件,(窗体)Netin 初始化。
End Sub
Private Sub Form_Load(sender As Object, e As EventArgs) Handles Me.Load
'加载后显示窗体Netin。
End Sub
Public Sub ObjClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,Button2.Click,Button3.Click,TextBox1.Click
MessageBox.Show("你按了鼠标")
End Sub
Public WithEvents TextBox1 As TextBox
Public WithEvents Button1 As Button
Public WithEvents Button2 As Button
Public WithEvents Button3 As Button
Friend WithEvents m As ContextMenuStrip
Friend WithEvents m1 As ToolStripMenuItem
End Class
Class MainWindow
Netin.Show()
Netin.Button2.Text = "Main"
……
大体看一下这个类里的事件都是私有的(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