以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 在窗口记录窗RecordGrid中如何调整行高及颜色 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=196279) |
||||
-- 作者:ZJZK2018 -- 发布时间:2025/4/14 21:53:00 -- 在窗口记录窗RecordGrid中如何调整行高及颜色 要求写在图片中: |
||||
-- 作者:有点蓝 -- 发布时间:2025/4/14 22:41:00 -- Dim bctr = Forms("窗口1").Controls("RecordGrid1").BaseControl bctr.Rows(0).Height = 50 指定某行行高 bctr.AutoSizeRow(7) 设置某一行自动行高 bctr.styles.Alternate.BackColor = Color.gray \'交替行颜色 |
||||
-- 作者:ZJZK2018 -- 发布时间:2025/4/15 12:50:00 -- 这记录窗中的行能否可以遍历,或根据列名进行对应设置行高? |
||||
-- 作者:有点蓝 -- 发布时间:2025/4/15 13:17:00 -- 可以遍历 for i as integer = 0 to bctr.Rows.count - 1 bctr.Rows(i).xxxx next
[此贴子已经被作者于2025/4/15 13:17:15编辑过]
|
||||
-- 作者:ZJZK2018 -- 发布时间:2025/4/15 17:19:00 -- 在记录窗中我需求是:当输入的内容超过行高50时,自动调整行高,否则行高按50,下面代码出错了,请老师指正一下,谢谢! \' 先定义测量文本高度的函数,放在最外层 Function MeasureTextHeight(text As String) As Integer \'这里只是简单示例返回值,实际要根据字体?字号等因素精确计算 Return text.Length * 2 End Function If Forms("招投标数据校验").Opened Then Dim bctr = Forms("招投标数据校验").Controls("RecordGrid1").BaseControl For i As Integer = 0 To bctr.Rows.Count - 1 bctr.Rows(i).Height = 50 Dim cellValue = bctr.Rows(i).Cells(0).Value If cellValue IsNot Nothing Then Dim text = cellValue.ToString() Dim textHeight = MeasureTextHeight(text) If textHeight > 50 Then bctr.Rows(i).Height = textHeight End If End If Next End If
|
||||
-- 作者:有点蓝 -- 发布时间:2025/4/15 19:44:00 -- If Forms("招投标数据校验").Opened Then Dim bctr = Forms("招投标数据校验").Controls("RecordGrid1").BaseControl For i As Integer = 0 To bctr.Rows.Count - 1 bctr.Rows(i).Height = 50 Dim cellValue as string = bctr.Rows(i)(1) If cellValue > "" Then Dim textHeight = MeasureTextHeight(cellValue ) If textHeight > 50 Then bctr.Rows(i).Height = textHeight End If End If Next End If
|
||||
-- 作者:ZJZK2018 -- 发布时间:2025/4/15 20:14:00 -- 出现错误提示: |
||||
-- 作者:有点蓝 -- 发布时间:2025/4/15 20:32:00 -- 不是自己定义的全局代码函数吗!如果还没有定义,重新到全局代码添加 |
||||
-- 作者:ZJZK2018 -- 发布时间:2025/4/15 21:50:00 -- 还是提示出错: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.8.18.1 错误所在事件:表,表A,AfterEdit 详细错误信息: 调用的目标发生了异常。 从类型“DBNull”到类型“String”的转换无效。
|
||||
-- 作者:有点蓝 -- 发布时间:2025/4/15 21:58:00 --
|