以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]求助合并代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=99332)

--  作者:jyh7081
--  发布时间:2017/4/17 15:58:00
--  [求助]求助合并代码

第一段或第二段代码单独使用,没有问题,合并到一起时,我把相同代码注释掉,显示“未设置对象变量或 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   \'第一列居右中


--  作者:有点色
--  发布时间:2017/4/17 16:11:00
--  

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

g1 = e.Form.Controls("RecordGrid2").BaseControl  \'自动行高
g1.AutoSizeRows

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   \'第一列居右中


--  作者:有点色
--  发布时间:2017/4/17 16:11:00
--  
 如果还有问题,单独做个例子上来。
--  作者:jyh7081
--  发布时间:2017/4/19 9:29:00
--  

首次进入“记录窗口录入”窗口,提示错误。不关闭项目,再次进入窗口,就正常了。

 

例子:

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:测试.table

[此贴子已经被作者于2017/4/19 9:58:11编辑过]

--  作者:有点色
--  发布时间:2017/4/19 9:47:00
--  

加上红色代码

 

Dim rt = e.form.Controls("Panel1").basecontrol.Controls("mytxt")
If rt Is Nothing Then Return