在VB.NET中怎样将进度条容入状态栏中?

ccg68 2004-08-29 07:53:41
在VB.NET中怎样将进度条容入状态栏中?我的意思不是将进度条放到状态栏上,而是进度条作为状态栏的一个Panel。
...全文
170 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
NoReady 2004-08-30
  • 打赏
  • 举报
回复
我这里有一个外国网友写的,没仔细看过,分2个文件 :
----------------------------
ProgressStatus.vb中的代码:

------------------
Public Class ProgressStatus : Inherits StatusBar
Public progressBar As New ProgressBar
Private _progressBar As Integer = -1

Sub New()
progressBar.Hide()

Me.Controls.Add(progressBar)
End Sub

Public Property setProgressBar() As Integer
Get
Return _progressBar
End Get
Set(ByVal Value As Integer)
_progressBar = Value
Me.Panels(_progressBar).Style = StatusBarPanelStyle.OwnerDraw
End Set
End Property

Private Sub Reposition(ByVal sender As Object, ByVal sbdevent As System.Windows.Forms.StatusBarDrawItemEventArgs) Handles MyBase.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



使用它的form1.vb的代码如下:
-------------------------
Public Class Form1
Inherits System.Windows.Forms.Form

#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

'Form 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.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Public StatusBar As New ProgressStatus

Private Sub InitializeStatusBar()
Dim info = New System.Windows.Forms.StatusBarPanel
Dim progress = New System.Windows.Forms.StatusBarPanel

info.Text = "Ready"
info.Width = 100

progress.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring

With StatusBar
.Panels.Add(info)
.Panels.Add(progress)
.ShowPanels = True
.setProgressBar = 1
.progressBar.Minimum = 0
.progressBar.Maximum = 100
End With

Me.Controls.Add(StatusBar)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeStatusBar()
StatusBar.progressBar.Value = 50
End Sub
End Class

dofly 2004-08-29
  • 打赏
  • 举报
回复
别人写的,好像是水如烟吧.
Public Class Form1
Inherits System.Windows.Forms.Form

#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

'Form 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.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 266)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Public StatusBar As New ProgressStatus

Private Sub InitializeStatusBar()
Dim info = New System.Windows.Forms.StatusBarPanel
Dim progress = New System.Windows.Forms.StatusBarPanel

info.Text = "Ready"
info.Width = 100

progress.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring

With StatusBar
.Panels.Add(info)
.Panels.Add(progress)
.ShowPanels = True
.setProgressBar = 1
.progressBar.Minimum = 0
.progressBar.Maximum = 100
End With

Me.Controls.Add(StatusBar)
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
InitializeStatusBar()
StatusBar.progressBar.Value = 50
End Sub
End Class

16,722

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧