【问题标题】:How to draw amount of blocks of the progressbar in VB.NET?如何在 VB.NET 中绘制进度条的块数?
【发布时间】:2018-11-27 08:47:15
【问题描述】:

进度条的最大值为 10。

所以我需要在运行进度之前绘制十个没有填充颜色的块。

编辑:添加代码

Public Class MyProgressBar
Inherits ProgressBar

Public Sub New()
    Me.ForeColor = Color.Red
End Sub

Protected Overrides Sub OnPaint(e As PaintEventArgs)
    MyBase.OnPaint(e)
  For i as integer = 1 to 10
     Dim g As Graphics = e.Graphics
     Dim widthScale As Integer = Me.Width/10
     g.DrawRectangle(Pens,Me.Left+(i*widthScale ),Me.Top, Me.Width / 10, Me.Height)
    End For
End Sub
End Class

我尝试覆盖 OnPaint() 但它不起作用。

【问题讨论】:

  • 你的问题是什么?你尝试了什么?你的代码在哪里?
  • 我尝试覆盖 OnPaint()。但它不起作用。

标签: vb.net visual-studio-2015 progress-bar


【解决方案1】:

有很多方法可以做到这一点。最简单的方法是创建框的透明图像并将其放在常规进度条的顶部。

或者您可以创建一个文本框数组,并调整它们的位置、边框和背景,直到它们看起来像您想要的那样。

更强大的图形处理方法是使用内置的.net graphics object。有简介here

【讨论】:

  • 这是评论,不是对当前无法回答的问题的回答。
猜你喜欢
  • 2011-04-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-17
  • 1970-01-01
相关资源
最近更新 更多