回答
如何只使用GDI +绘制自己。
您可以稍后将其转换为您自己的usercontrol,但这会让您开始。它应该是相当自我解释:
Private Sub Form2_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint
DrawProgress(e.Graphics, New Rectangle(5, 5, 60, 60), 40)
DrawProgress(e.Graphics, New Rectangle(80, 5, 60, 60), 80)
DrawProgress(e.Graphics, New Rectangle(155, 5, 60, 60), 57)
End Sub
Private Sub DrawProgress(g As Graphics, rect As Rectangle, percentage As Single)
'work out the angles for each arc
Dim progressAngle = CSng(360/100 * percentage)
Dim remainderAngle = 360 - progressAngle
'create pens to use for the arcs
Using progressPen As New Pen(Color.LightSeaGreen, 2), remainderPen As New Pen(Color.LightGray, 2)
'set the smoothing to high quality for better output
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
'draw the blue and white arcs
g.DrawArc(progressPen, rect, -90, progressAngle)
g.DrawArc(remainderPen, rect, progressAngle - 90, remainderAngle)
End Using
'draw the text in the centre by working out how big it is and adjusting the co-ordinates accordingly
Using fnt As New Font(Me.Font.FontFamily, 14)
Dim text As String = percentage.ToString + "%"
Dim textSize = g.MeasureString(text, fnt)
Dim textPoint As New Point(CInt(rect.Left + (rect.Width/2) - (textSize.Width/2)), CInt(rect.Top + (rect.Height/2) - (textSize.Height/2)))
'now we have all the values draw the text
g.DrawString(text, fnt, Brushes.Black, textPoint)
End Using
End Sub
输出
谢谢......这工作得很好,但如果你知道如何让它比“HighQuality”更高? – faresabb2
老兄,你是高手! –
@ faresabb2在在代码的最开始的Form2.Paint子,把
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality
谢谢....我会告诉你它是否有效。 – faresabb2
这里是一个如何在需要时更新进度循环栏的示例,而不会因刷新而闪烁。
基于马特的代码
只要将代码拷贝到您的形式Paint事件中,适当地改变矩形的大小和位置,以托管在表单中的圈子。 百分比是一个全局变量,当它发生变化时,可以调用me.refresh()方法来触发重绘!
Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim rect As New Rectangle(70, 45, 90, 90)
Dim curvatura_progress = CSng(360/100 * percent)
Dim curvatura_rimanente = 360 - curvatura_progress
Using tratto_progresso As New Pen(Color.Lime, 4), tratto_rimanente As New Pen(Color.White, 4)
g.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
g.DrawArc(tratto_progresso, rect, -90, curvatura_progress)
g.DrawArc(tratto_rimanente, rect, curvatura_progress - 90, curvatura_rimanente)
End Using
Using fnt As New Font(Me.Font.FontFamily, 14)
Dim text As String = percent.ToString + "%"
Dim textSize = g.MeasureString(text, fnt)
Dim textPoint As New Point(CInt(rect.Left + (rect.Width/2) - (textSize.Width/2)), CInt(rect.Top + (rect.Height/2) - (textSize.Height/2)))
g.DrawString(text, fnt, Brushes.Black, textPoint)
End Using
End Sub
只需添加Dim percent As Single这可能会错过BR1COP –
LabelSec.Text = DateTime.Now.ToString("ss")
LabelTime.Text = DateTime.Now.ToString("hh:mm tt")
CircularProgressBar1.Value = Convert.ToInt32(LabelSec.Text)
试试这个家伙...这是使用进度为塞康代码
- 1. 圆形进度条
- 2. 圆形UILabel圆形进度条
- 3. 圆形进度条css
- 4. 圆形边框进度条
- 5. WPF:圆形进度条
- 6. 圆形进度条(css)
- 7. 弯曲圆形进度条
- 8. 圆形进度条Android
- 9. Android - 圆角方形线条进度条
- 10. CSS或jQuery/JavaScript椭圆形/圆形方形进度条
- 11. c#xamarin圆形进度条 - Android
- 12. 圆形进度条大小对齐
- 13. Android圆形进度条大小
- 14. jQuery动画圆形进度条
- 15. 角2中的圆形进度条
- 16. Xamarin.UWP:如何制作圆形进度条
- 17. 使用Tkinter的圆形进度条?
- 18. 使用壁画的圆形进度条
- 19. GWT中的圆形进度条
- 20. 带指示器的圆形进度条
- 21. Java中的圆形进度条显示
- 22. 在圆形进度条中清除progressDrawable
- 23. 使用JavaScript的圆形进度条
- 24. 圆形进度条中的渐变
- 25. Windows窗体中的圆形进度条
- 26. 旋转圆形进度条对面
- 27. 用html5制作圆形进度条sgg
- 28. Unity 3D中的圆形进度条 - UnityScript
- 29. 动态扩展视觉基本形式
- 30. 圆形进度条中的圆形边Android
看到http://www.codeproject.com/Articles/30625/Circular-Progress-Indicator和也是http://www.codeproject.com/Articles/14855/SQL-Server-Circular-Progress-Bar – Plutonix
这是用C++构建的,我想用visual basic构建它。 – faresabb2
它们在**中不是**;他们可以很容易地转换为VB。关键是他们(和其他人)已经建成并准备使用;你不必重新创建轮子。 – Plutonix