以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  定义单元格字体  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=79447)

--  作者:一笑
--  发布时间:2015/12/31 16:55:00
--  定义单元格字体
如何用代码定义表中某些单元格的字体,不如加粗、字体、大小等(自定义样式选项太少),谢谢
[此贴子已经被作者于2015/12/31 17:08:45编辑过]

--  作者:大红袍
--  发布时间:2015/12/31 17:08:00
--  

必须用drawcell事件。

 

http://www.foxtable.com/help/topics/0656.htm

 


--  作者:一笑
--  发布时间:2015/12/31 17:18:00
--  
选项太少 不能设置字体和大小
--  作者:大红袍
--  发布时间:2015/12/31 19:35:00
--  
If e.Col.name = "第二列" Then
    Dim cl = e.Table.grid.getCellRange(e.Row.index+1, e.Col.index+1)
    If e.Row("第二列") = "D" Then
        If cl.style Is Nothing Then
            Dim t As Table = e.Table
            Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add("cs1")
            cs1.backcolor = Color.Red
            cs1.font = new font ("宋体", 12)
            cl.style = cs1
        End If
    Else
        cl.Style = Nothing
    End If
End If

--  作者:一笑
--  发布时间:2016/1/1 8:49:00
--  
帮助文档中有关字体,http://www.foxtable.com/help/index.html?n=0395.htm#userconsent#

Dim fnt As New Font(CurrentTable.Font.Name, 14CurrentTable.Font.Style)
CurrentTable
.Font = fnt
这种设置只能用于当前表吗?能用于单元格设置吗?能用于drawcell事件中吗?谢谢
[此贴子已经被作者于2016/1/1 9:08:02编辑过]

--  作者:大红袍
--  发布时间:2016/1/3 23:16:00
--  

可以用 C1.Win.C1FlexGrid.CellStyle  临时性的设置样式,如4楼的代码

 

但是,设置是不保存的,所以要写到drawcell事件不断的设置。

 


--  作者:一笑
--  发布时间:2016/1/4 15:44:00
--  
在drawcell中写入了代码,让指定单元格进行了加粗,但是加粗字体大小恢复到默认值,我想设置为楷体,14号,必须用4楼代码?写在哪呢?谢谢
If e.Row("选择") = True Then
    e.Style = "加粗"
End If


--  作者:大红袍
--  发布时间:2016/1/4 15:49:00
--  
Dim cl = e.Table.grid.getCellRange(e.Row.index+1, e.Col.index+1)
If e.Row("选择") = True Then
    If cl.style Is Nothing Then
        Dim t As Table = e.Table
        Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.grid.Styles.Add("cs1")
        cs1.backcolor = Color.Red
        cs1.font = new font ("宋体", 12)
        cl.style = cs1
    Else
        cl.style.backcolor = Color.Red
        cl.Style.font = new font ("宋体", 12)
    End If
Else
    cl.Style = Nothing
End If

 


--  作者:一笑
--  发布时间:2016/1/4 16:13:00
--  
加粗设置在哪儿?我把cl.style.backcolor = Color.Red已经删掉,为何底色还是红色?谢谢
--  作者:大红袍
--  发布时间:2016/1/4 16:25:00
--  

1、设置成 cl.style.backcolor = Color.White

 

2、加粗参考 http://www.foxtable.com/help/topics/0494.htm