You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

自定义3D进度条缺失Step与PerformStep属性的添加方法求助

为自定义3D进度条控件RmCustProgressBar添加Step和PerformStep属性

临时替代方案(无需修改控件源代码)

如果没有控件的源代码,可以直接在业务代码里模拟Step和PerformStep的功能,无需改动控件本身:

Public Sub righeNere()
    Dim row_count As Integer = DataGridView1.Rows.Count
    RmCustProgressBar1.MaxValue = row_count
    ' 自行定义进度步长
    Dim progressStep As Integer = 1
    Dim currencyManager1 As CurrencyManager = CType(DataGridView1.BindingContext(DataGridView1.DataSource), CurrencyManager)
    
    For Each rw As DataGridViewRow In DataGridView1.Rows
        If rw.Cells(2).Style.BackColor = Color.Gold Or rw.Cells(3).Style.BackColor = Color.Gold Or rw.Cells(4).Style.BackColor = Color.Gold Or rw.Cells(5).Style.BackColor = Color.Gold Or rw.Cells(6).Style.BackColor = Color.Gold Or rw.Cells(7).Style.BackColor = Color.Gold Then
            rw.Visible = True
            Continue For
        ElseIf rw.Cells(2).Style.BackColor = Color.White Or rw.Cells(3).Style.BackColor = Color.White Or rw.Cells(4).Style.BackColor = Color.White Or rw.Cells(5).Style.BackColor = Color.White Or rw.Cells(6).Style.BackColor = Color.White Or rw.Cells(7).Style.BackColor = Color.White Then
            currencyManager1.SuspendBinding()
            rw.Visible = False
            currencyManager1.ResumeBinding()
            ' 模拟PerformStep:将当前进度值加上步长,不超过最大值
            RmCustProgressBar1.Value = Math.Min(RmCustProgressBar1.Value + progressStep, RmCustProgressBar1.MaxValue)
        End If
    Next
End Sub

永久解决方案(修改控件源代码添加属性)

如果能获取到RmCustProgressBar的源代码(一般是VB类库项目),可以直接为控件添加这两个属性和方法:

  1. 打开控件的类代码文件,在类内部添加私有字段和Step属性:
' 存储步长的私有变量
Private _step As Integer = 1

' 公开Step属性
Public Property Step() As Integer
    Get
        Return _step
    End Get
    Set(ByVal value As Integer)
        ' 确保步长不为负数
        If value >= 0 Then
            _step = value
        End If
    End Set
End Property
  1. 添加PerformStep方法:
Public Sub PerformStep()
    ' 增加当前进度值,确保不超过最大值
    Me.Value = Math.Min(Me.Value + _step, Me.MaxValue)
End Sub
  1. 重新编译控件类库,然后在你的窗体项目中替换引用新编译的控件即可。

内容的提问来源于stack exchange,提问作者user19103492

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 01:55:19