Dim bctr = Forms("窗口1").Controls("RecordGrid1").BaseControl
bctr.Rows(0).Height = 50 指定某行行高
bctr.AutoSizeRow(7) 设置某一行自动行高
bctr.styles.Alternate.BackColor = Color.gray '交替行颜色
这记录窗中的行能否可以遍历,或根据列名进行对应设置行高?
可以遍历
for i as integer = 0 to bctr.Rows.count - 1
bctr.Rows(i).xxxx
next
[此贴子已经被作者于2025/4/15 13:17:15编辑过]
在记录窗中我需求是:当输入的内容超过行高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
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
不是自己定义的全局代码函数吗!如果还没有定义,重新到全局代码添加
还是提示出错:.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2022.8.18.1
错误所在事件:表,表A,AfterEdit
详细错误信息:
调用的目标发生了异常。
从类型“DBNull”到类型“String”的转换无效。