首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >处理VScrollbar Paint事件

处理VScrollbar Paint事件
EN

Stack Overflow用户
提问于 2016-06-30 23:04:57
回答 0查看 741关注 0票数 0

我一直在尝试处理窗体上控件的Paint事件。然而,事件从未得到处理,我不确定我做错了什么。我已经创建了一个非常简单的WinForms项目来演示这一点(我已经包含了生成的设计器代码,以显示没有其他代码):

Form1.vb

代码语言:javascript
复制
Public Class Form1
    Private Sub Form1_Load( sender As Object,  e As EventArgs) Handles MyBase.Load
        AddHandler VScrollBar1.Paint, AddressOf VScrollBar1_Paint
    End Sub

    Private Sub VScrollBar1_Paint (ByVal sender As Object, ByVal e As PaintEventArgs)
        Dim str As String = "test"
        System.Windows.Forms.MessageBox.Show(str)
    End Sub                              
End Class

Form1.Designer.vb

代码语言:javascript
复制
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Me.VScrollBar1 = New System.Windows.Forms.VScrollBar()
        Me.SuspendLayout
        '
        'VScrollBar1
        '
        Me.VScrollBar1.Location = New System.Drawing.Point(26, 56)
        Me.VScrollBar1.Name = "VScrollBar1"
        Me.VScrollBar1.Size = New System.Drawing.Size(17, 80)
        Me.VScrollBar1.TabIndex = 0
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(284, 261)
        Me.Controls.Add(Me.VScrollBar1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(false)

    End Sub
        Friend WithEvents VScrollBar1 As System.Windows.Forms.VScrollBar

End Class

永远不会处理该事件,但可以正确绘制控件。我遗漏了什么?

EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38126980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档