none
自定义组件屏蔽事件求教各位,谢谢!!! RRS feed

  • 问题

  • 在学习做一个组件,继承了 Inherits System.Windows.Forms.Control

    在组件的事件里有Parint事件,我想把它隐藏或屏蔽掉,用了下面方法不见效果,求教,谢谢!!!

      <EditorBrowsable(EditorBrowsableState.Never), Browsable(False)> _
        Public Shadows Custom Event parint As PaintEventHandler
            AddHandler(ByVal value As PaintEventHandler)
                AddHandler MyBase.Paint, value
            End AddHandler
            RemoveHandler(ByVal value As PaintEventHandler)
                RemoveHandler MyBase.Paint, value
            End RemoveHandler
            RaiseEvent(ByVal sender As Object, ByVal e As PaintEventArgs)
            End RaiseEvent
        End Event

    2012年11月5日 0:28

答案

  • 你好,

    我看到你在隐藏Paint事件的时候拼写的好像有错误,请检查一下,在EditorBrowsable属性为false之后,在默认的智能提示里面是不会出现这个事件的。

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us

    • 已标记为答案 YQY888 2012年11月10日 7:49
    2012年11月6日 7:28
    版主

全部回复

  • 写一个组件,继承了Inherits System.Windows.Forms.Control
    我想屏蔽Private Sub Component1_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint

    用下面代码,没有效果,还请大家帮助,谢谢!!!

    Public Shadows Custom Event parint As PaintEventHandler        AddHandler(ByVal value As PaintEventHandler)            AddHandler MyBase.Paint, value        End AddHandler        RemoveHandler(ByVal value As PaintEventHandler)            RemoveHandler MyBase.Paint, value        End RemoveHandler        RaiseEvent(ByVal sender As Object, ByVal e As PaintEventArgs)        End RaiseEvent    End Event

    是不是这段画图有联系:

    Protected Overrides Sub OnPaintBackground(pevent As PaintEventArgs)        MyBase.OnPaintBackground(pevent)        ncountn = Me        Me.DoubleBuffered = True        Me.Height = Me.Font.Height        If Me.DesignMode = True Then Exit Sub        If timerboon = False Then Timec.Stop()        If timerboon = True Then Timec.Interval = 500 : Timec.Start()     End Sub    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)        MyBase.OnPaint(e)          Me.DoubleBuffered = True        Me.Height = Me.Font.Height        DrawBorder(e.Graphics, Me.DisplayRectangle)    End Sub

    2012年11月5日 8:14
  • 用下面代码,没有效果,还请大家帮助,谢谢!!!

    Public Shadows Custom Event parint As PaintEventHandler
            AddHandler(ByVal value As PaintEventHandler)
                AddHandler MyBase.Paint, value
            End AddHandler
            RemoveHandler(ByVal value As PaintEventHandler)
                RemoveHandler MyBase.Paint, value
            End RemoveHandler
            RaiseEvent(ByVal sender As Object, ByVal e As PaintEventArgs)
            End RaiseEvent
        End Event

    是不是这段画图有联系:

     Protected Overrides Sub OnPaintBackground(pevent As PaintEventArgs)
            MyBase.OnPaintBackground(pevent)
            ncountn = Me
            Me.DoubleBuffered = True
            Me.Height = Me.Font.Height
            If Me.DesignMode = True Then Exit Sub
            If timerboon = False Then Timec.Stop()
            If timerboon = True Then Timec.Interval = 500 : Timec.Start()
        End Sub
        Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
            MyBase.OnPaint(e)
                    Me.DoubleBuffered = True
            Me.Height = Me.Font.Height
            DrawBorder(e.Graphics, Me.DisplayRectangle)      
        End Sub

    2012年11月5日 8:17
  • 你好,

    我看到你在隐藏Paint事件的时候拼写的好像有错误,请检查一下,在EditorBrowsable属性为false之后,在默认的智能提示里面是不会出现这个事件的。

    Best regards,


    Shanks Zen
    MSDN Community Support | Feedback to us

    • 已标记为答案 YQY888 2012年11月10日 7:49
    2012年11月6日 7:28
    版主
  • 谢谢!!!可能是哪出错了,已能实现,谢谢!!!
    2012年11月10日 7:49