以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]不同区域设置不同标题颜色【已解决】  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=99527)

--  作者:baiheinet
--  发布时间:2017/4/20 21:24:00
--  [求助]不同区域设置不同标题颜色【已解决】
CurrentTable.grid.GetCellRange(0,1,0,31).style.BackColor = Color.Yellow 
CurrentTable.grid.GetCellRange(0, 31, 0, 38).style.BackColor = Color.Lime

错误 不知为什么
[此贴子已经被作者于2017/4/21 7:41:48编辑过]

--  作者:有点色
--  发布时间:2017/4/20 21:30:00
--  
Dim g = Tables("表A").grid
Dim cs = g.GetCellRange(3, 3)
If cs.style Is Nothing Then
    cs.style = g.Styles.add("test")
End If
cs.Style.backcolor = color.red
 

--  作者:baiheinet
--  发布时间:2017/4/20 21:46:00
--  
你这只能设置一个区域 ,我要同时设置不同区域不同颜色了
--  作者:有点色
--  发布时间:2017/4/20 21:47:00
--  

 参考2楼的方法,要判断 If cs.style Is Nothing Then


--  作者:baiheinet
--  发布时间:2017/4/21 7:11:00
--  
虽然不太懂原理 但是 这样好了
Dim g = CurrentTable.grid
Dim cs = g.GetCellRange(0,1,0, 31)
Dim cs2 = g.GetCellRange(0,32,0, 39)
Dim cs3 = g.GetCellRange(0,40,0, 48)
Dim cs4 = g.GetCellRange(0,49,0, 83)
If cs.style Is Nothing Then
cs.style = g.Styles.add("test")
End If
If cs2.style Is Nothing Then
cs2.style = g.Styles.add("test2")
End If
If cs3.style Is Nothing Then
cs3.style = g.Styles.add("test3")
End If
If cs4.style Is Nothing Then
cs4.style = g.Styles.add("test4")
End If
cs.Style.backcolor = color.Yellow
cs2.Style.backcolor = color.Lime
cs3.Style.backcolor = color.DarkTurquoise
cs4.Style.backcolor = color.red