progress.vb
来自「Samples are organized by chapter, and th」· VB 代码 · 共 108 行
VB
108 行
Public Class Progress
Inherits System.Windows.Forms.UserControl
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
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.
Friend WithEvents Bar As System.Windows.Forms.ProgressBar
Friend WithEvents lblProgress As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Bar = New System.Windows.Forms.ProgressBar()
Me.lblProgress = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Bar
'
Me.Bar.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.Bar.Location = New System.Drawing.Point(4, 8)
Me.Bar.Name = "Bar"
Me.Bar.Size = New System.Drawing.Size(154, 32)
Me.Bar.TabIndex = 0
'
'lblProgress
'
Me.lblProgress.Anchor = ((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right)
Me.lblProgress.Location = New System.Drawing.Point(4, 48)
Me.lblProgress.Name = "lblProgress"
Me.lblProgress.Size = New System.Drawing.Size(152, 16)
Me.lblProgress.TabIndex = 1
Me.lblProgress.Text = "0% Done"
Me.lblProgress.TextAlign = System.Drawing.ContentAlignment.TopCenter
'
'Progress
'
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblProgress, Me.Bar})
Me.Font = New System.Drawing.Font("Tahoma", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Name = "Progress"
Me.Size = New System.Drawing.Size(164, 68)
Me.ResumeLayout(False)
End Sub
#End Region
Property Value() As Integer
Get
Return Bar.Value
End Get
Set(ByVal Value As Integer)
Bar.Value = Value
UpdateLabel()
End Set
End Property
Property Maximum() As Integer
Get
Return Bar.Maximum
End Get
Set(ByVal Value As Integer)
Bar.Maximum = Value
End Set
End Property
Property [Step]() As Integer
Get
Return Bar.Step
End Get
Set(ByVal Value As Integer)
Bar.Step = Value
End Set
End Property
Public Sub PerformStep()
Bar.PerformStep()
UpdateLabel()
End Sub
Private Sub UpdateLabel()
lblProgress.Text = ((Bar.Value * 100) \ Bar.Maximum).ToString() & "% Done"
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?