以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教老师,为什么drawcell事件无效?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=129138)

--  作者:houseer
--  发布时间:2018/12/22 11:35:00
--  请教老师,为什么drawcell事件无效?
If  e.Col.Name = "单价" Then
    If e.Row(e.Col.Name) = 0 Then 
        e.Style = "红色"
    End If
End If

已经定义了"红色"的方案。

表是sqltable类型的表,代码用sqlcommand返回的数据集当成它的datascorce。

我在窗体上的table控件上 drawcell 里写的上述代码。 可是发现无效。 问题出在哪呢?

--  作者:有点蓝
--  发布时间:2018/12/22 11:39:00
--  
设置datascorce的要到全局表事件drawcell 写,注意要在设置datascorce启用全局表事件drawcell
--  作者:houseer
--  发布时间:2018/12/22 12:36:00
--  
是这样吗老师:
在窗口的afterload事件里:

Dim tb1 As WinForm.Table = e.Form.Controls("Table1")
tb1.Table.DataSource  = dt3
dt3.GlobalHandler.DrawCell = True \'开启全局表事件


全局表事件的drawcell里:

Dim tb1 As WinForm.Table = Forms("窗口1").Controls("Table1")

Select Case e.Table.Name
    Case tb1.Table.Name
        If  e.Col.Name = "单价" Then
            If e.Row(e.Col.Name) = 0 Then
                e.Style = "红色"
            End If
        End If
End Select



这样还是不行啊? 求老师给看看

另外再问一下老师:是不是没有开启表事件,CurrentChanged、PositionChanged、AfterSelChange、AfterSelRangeChange这四个事件,在窗体的table事件里和 全局表事件里都有效。
而对其他表事件,即使开启了,也只能在全局表事件里写。  在窗体上写无效。
是这样吗?

--  作者:有点蓝
--  发布时间:2018/12/22 14:15:00
--  
样式也要动态添加:

Dim tb1 As WinForm.Table = e.Form.Controls("Table1")
tb1.Table.DataSource  = dt3
tb1.Table.DataTable.GlobalHandler.DrawCell = True \'开启全局表事件
tb1.Table.DataTable.AddUserStyle("红色", Color.Red, Color.White)