Private strDate = New System.Windows.Forms.StatusBarPanel
Private StrCount = New System.Windows.Forms.StatusBarPanel
Private info = New System.Windows.Forms.StatusBarPanel
Private progress = New System.Windows.Forms.StatusBarPanel
Private StatusBar As New ProgressStatus ''状态条中加入进度条
PrivateSub InitializeStatusBar()Sub InitializeStatusBar() info.Text ="Ready" info.Width =100 StrCount.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents StrCount.Alignment = HorizontalAlignment.Center StrCount.Text ="完成 0 条记录" progress.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring strDate.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents strDate.Text = System.DateTime.Now strDate.Alignment = HorizontalAlignment.Right With StatusBar .Panels.Add(info) .Panels.Add(progress) .Panels.Add(StrCount) .Panels.Add(strDate) .ShowPanels =True .setProgressBar =1 .progressBar.Minimum =0 .progressBar.Maximum =100 EndWith Me.Controls.Add(StatusBar) End Sub
组件类:ProgressStatus.vb
PublicClass ProgressStatusClass ProgressStatus : Inherits StatusBar Public progressBar AsNew progressBar Private _progressBar AsInteger=-1 Sub New()SubNew() progressBar.Hide() Me.Controls.Add(progressBar) End Sub PublicProperty setProgressBar()Property setProgressBar() AsInteger Get Return _progressBar EndGet Set(ByVal Value AsInteger) _progressBar = Value Me.Panels(_progressBar).Style = StatusBarPanelStyle.OwnerDraw EndSet End Property PrivateSub Reposition()Sub Reposition(ByVal sender AsObject, ByVal sbdevent As System.Windows.Forms.StatusBarDrawItemEventArgs) HandlesMyBase.DrawItem progressBar.Location =New Point(sbdevent.Bounds.X, sbdevent.Bounds.Y) progressBar.Size =New Size(sbdevent.Bounds.Width, sbdevent.Bounds.Height) progressBar.Show() End Sub End Class
Private strDate = New System.Windows.Forms.StatusBarPanel Private StrCount = New System.Windows.Forms.StatusBarPanel Private info = New System.Windows.Forms.StatusBarPanel Private progress