第一段或第二段代码单独使用,没有问题,合并到一起时,我把相同代码注释掉,显示“未设置对象变量或 With 块变量。”
第一段:
Dim g1 = e.Form.Controls("RecordGrid1").BaseControl
If vars("xy") <> CurrentTable.Position & "," & g1.selection.r1 Then
vars("xy") = CurrentTable.Position & "," & g1.selection.r1
Dim rt = e.form.Controls("Panel1").basecontrol.Controls("mytxt")
rt.text = iif(g1(g1.Selection.r1, 1) Is dbnull.value, "", g1(g1.Selection.r1, 1))
rt.Select(0, rt.text.length)
rt.SelectionFont = New Font("仿宋_GB2312",15) '字体字号
rt.SelectionStart = rt.text.length
End If
第二段:
’Dim g1 = e.Form.Controls("RecordGrid2").BaseControl ’自动行高
g1.AutoSizeRows
’Dim g1 = e.Form.Controls("RecordGrid1").basecontrol ’第一行第二列样式
Dim rng As C1.Win.C1FlexGrid.CellRange = g1.GetCellRange(0, 1, 0, 1)
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = g1.Styles.Add("样式1")
cs1.TextAlign = 4 '居中
cs1.Font = new font("宋体", 20)
rng.style = cs1
Dim rng1 As C1.Win.C1FlexGrid.CellRange = g1.GetCellRange(1, 1, 1, 1) ’第二行第二列样式
Dim cs2 As C1.Win.C1FlexGrid.CellStyle = g1.Styles.Add("样式2")
cs2.TextAlign = 4 '居中
cs2.Font = new font("方正小标宋简体", 24)
rng1.style = cs2
Dim rgd As object = e.Form.Controls("RecordGrid1").basecontrol ’标题样式
rgd.cols(0).Style.Font = New Font("微软雅黑", 10, FontStyle.Bold) '设置字体
rgd.cols(0).Width = 140 '第一列列宽
rgd.cols(0).TextAlign = 6 '第一列居右中