大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
怎么会捏,你是不是没有加上mybase.keypress
成都创新互联公司主要从事网站设计制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务虞城,十余年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792
正确的重写步骤:新建一个Component-类下面一行写上Inherits
TextBox-然后写入:
Protected
Overrides
Sub
OnKeyPress(ByVal
e
As
System.Windows.Forms.KeyPressEventArgs)
MyBase.OnKeyPress(e)'这个东东是原来的keypress执行的代码,它会引发keypress事件
'-----这里写代码
End
Sub
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim a As New month(1)
MessageBox.Show(a.ToString)
End Sub
End Class
Public Class month
Dim m As Integer
Public Sub New(i As Integer)
m = i
End Sub
Public Overrides Function ToString() As String
If m = 1 And m = 12 Then
Return Choose(m, "一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二") + "月"
Else
Return m.ToString
End If
End Function
End Class
新建一个Winform,在和Form1平行的位置粘贴如下代码
Public Class MyLabel Inherits Label Protected Overrides Sub OnPaint(e As PaintEventArgs) e.Graphics.DrawEllipse(New Pen(Color.Red), New Rectangle(2, 2, 10, 10)) MyBase.OnPaint(e) End Sub End Class
运行,停掉,在工具箱找到MyLabel,拖动就可以看到效果。这只是最基本的重写,要模仿QQ还需要其他技术以及美工。