vb.net 类中属性中的事件 并向新加窗体中用代码添加控件
2013-06-10 10:28
597 查看
Public Class Form1 WithEvents s As New Student Dim ss As New Student Private Sub s_Fail(ByVal frm As Form, ByVal str As String) Handles s.Fail Dim g As Graphics = frm.CreateGraphics Dim f As Font = New Font("宋体", 30, FontStyle.Bold) Dim br As SolidBrush = New SolidBrush(Color.Red) frm.Size = New Size(400, 500) Dim z_text = New TextBox z_text.Location = New System.Drawing.Point(70, 80) z_text.Size = New Size(120, 21) z_text.Text = str frm.Show() frm.Controls.Add(z_text) g.DrawString(str, f, br, 30, 40) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click s.学号 = Val(TextBox1.Text) s.姓名 = TextBox2.Text s.成绩 = Val(TextBox3.Text) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Debug.WriteLine(s.学号) Debug.WriteLine(s.姓名) Debug.WriteLine(s.成绩) End Sub End Class Public Class Student Private No As Integer Private Name As String Private Score As Integer Public Event Fail(ByVal frm As Form, ByVal str As String) Public Sub New() No = 123 Name = "zxl" Score = 100 End Sub Public Property 学号() As Integer Get Return No End Get Set(ByVal value As Integer) If value <> 0 Then No = value End If End Set End Property Public Property 姓名() As String Get Return Name End Get Set(ByVal value As String) If value <> "" Then Name = value End If End Set End Property Public Property 成绩() As Integer Get Return Score End Get Set(ByVal value As Integer) Score = value If value <> 0 Then If (Score < 60) Then RaiseEvent Fail(New Form, "成绩:::" + value.ToString()) End If End If End Set End Property End Class
相关文章推荐
- vb.net 类中属性中的事件 并向新加窗体中用代码添加控件
- 章鱼哥—VB.NET 如何实现代码自动生成控件 添加绑定事件
- 在asp.net中为Web用户控件添加属性和事件
- VB.NET自定义控件 —— 添加控件自定义属性
- 【原创】vb.net 动态控件 事件添加
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- vs.net 2003下vb.net项目中控件属性栏没有事件图标的诡异现象
- [VB.NET]VB.NET2005中怎样实现子窗体控制父窗体的控件属性?
- 在asp.net中为Web用户控件添加属性和事件
- asp.net中后台给控件添加属性的方法代码
- 在asp.net中为Web用户控件添加属性和事件
- asp.net中后台给控件添加属性的方法代码
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- 在asp.net中为Web用户控件添加属性和事件
- VB.NET在窗体上添加任意动态控件