telerik 表格 行号_行号和其他颜色为连续表格

telerik 表格 行号

搜索网络时,我发现了一种简单的技术,可以将行号和交替色(对于偶数行和不均匀行)添加到连续形式中。

第一步 :创建一个文本框,将其发送到背景并选择第一种颜色。

.ControlSouce = fRowNum(False)

。名称= RowNum

第二步 :将以下功能添加到表单模块:(用于行号)

Public Function fRowNum(Reset As Boolean) As Long
Static I As Integer 
If Reset = True Then
   I = 0
   Exit Function
End If
'Add Row Numbers to Continuous Forms:
I = I + 1
fRowNum = I 
End Function 
第三步 :将以下代码添加到窗体OnOpen或OnLoad事件或任何其他包含Requery的事件中,以便正确地重新计算行号:
me.fRowNum False
第四步 :将以下代码添加到窗体的OnOpen或OnLoad事件,或通过“条件格式”面板添加条件:(用于替代颜色)。 在使用代码之前,创建一个文本框RowColor,其宽度为整个表单的其他颜色,将其发送到背景,并使其他控件的背景色透明。
 
Dim objColor As FormatCondition 
    Set objColor = Forms![myForm]![RowColor].FormatConditions.Add(acExpression, , "[RowNum] Mod 2 = 0") 
    With Forms![myForm]![RowColor].FormatConditions(0)
       .BackColor = 15132390
    ' or whatever color you choose for your alternating rowcolor...
    End With 
    Set objColor = Nothing 
现在,该表格将显示行号和其他颜色。 这是一种简单的方法,但是有一个“ bug”-如果用户在启动表单后(在计算行时)在表单的详细信息上使用鼠标玩游戏或在前几个实例中使用滚动条玩游戏,行号即将混乱,备用颜色也是如此,因为它们取决于行号。

关于如何改善这一点的任何建议?

干杯,迈克尔。

编者注:Michael进行了更多工作,然后提出了此解决方案。

这是一个完整的说明,该说明可以牢固运行,而不会出现任何滚动或刷新问题。 归功于

斯蒂芬·勒班Stephen Lebans)负责编号功能代码,并进入Experts-exchange.com董事会以整合整体解决方案: 第一步 :将以下功能添加到现有或新的项目模块中:
Public Function RowNum(frm As Form) As Variant
On Error GoTo Err_RowNum
    'Purpose:   Numbering the rows on a form.
    'Usage:     Text box with ControlSource of:  =RowNum([Forms]![myForm]) 
    With frm.RecordsetClone
        .Bookmark = frm.Bookmark
        RowNum = .AbsolutePosition + 1
    End With 
Exit_RowNum:
    Exit Function 
Err_RowNum:
    If Err.Number <> 3021& Then  'Ignore "No bookmark" at new row.
        Debug.Print "RowNum() error " & Err.Number & " - " & Err.Description
    End If
    RowNum = Null
    Resume Exit_RowNum
End Function 
第二步:将行号文本框添加到您的项目的任何形式的具有以下属性:

。名称= RowNum

.ControlSource = = RowNum([Forms]![myForm])

第三步:要使用其他颜色,请添加一个具有整个表单宽度的文本框,将其发送到背景,然后将其他控件的背景色(和边框)设置为透明。 将条件格式对话框与条件表达式一起使用:对于偶数行,[RowNum] mod 2 = 0,或者为On Load或On Open事件在项目模块中添加以下代码:

Dim objColor As FormatCondition 
Forms![myForm][RowColor].FormatConditions.Delete 
Set objColor = Forms![myForm]![RowColor].FormatConditions.Add(acExpression, , "[RowNum] Mod 2 = 0") 
With Forms![myForm]![RowColor].FormatConditions(0)
       .BackColor = vbGrey ' or whatever color you choose for your alternating rowcolor...
End With
Set objColor = Nothing 

翻译自: https://bytes.com/topic/net/insights/594455-row-numbers-alternate-colors-continuous-form

telerik 表格 行号

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值