以文本方式查看主题

-  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=124801)

--  作者:81538475
--  发布时间:2018/9/14 0:06:00
--  [求助]窗口表格中的颜色标记问题
窗口表格中的drawcell 中添加下面代码,但是窗口表没有_identify 列。应该如何处理呢。。

If e.Row.IsNull("第一列") = False Then
    Dim n As String = "样式" & e.Row("_Identify") & "_" & e.Col.name
    Dim ary() As String = e.Row("第一列").split("|")
    For Each s As String In ary
        Dim a() As String = s.split(":")
        If a(0) = e.Col.name Then
            e.Table.DataTable.AddUserStyle(n, Color.FromARGB(a(1)), Color.black)
            e.Table.DataTable.Styles(n).BackColor = Color.FromARGB(a(1))
            e.style = n
            Exit For
        End If
    Next
End If

--  作者:有点甜
--  发布时间:2018/9/14 9:11:00
--  
把 _Identify 列改成你表格里面的某一列即可(但此列必须唯一),也可以几列一起组合成一个唯一的字符串。
--  作者:81538475
--  发布时间:2018/9/14 9:55:00
--  
哦。好的。另外。我在颜色记录列的记录是这样的  职务:-1015680|数量:-65536。那我想做一个功能,就是还原颜色,如何把    
某一个去掉呢,用 trim 好像不行。
[此贴子已经被作者于2018/9/14 9:58:21编辑过]

--  作者:有点甜
--  发布时间:2018/9/14 10:06:00
--  

参考

 

Dim str As String = "职务:-1015680|数量:-65536"
Dim ss As String = "职务"
Dim nstr As String = ""
For Each s As String In str.split("|")
    If s.StartsWith(ss) = False Then
        nstr &= s & "|"
    End If
Next
msgbox(nstr.trim("|"))


--  作者:81538475
--  发布时间:2018/9/14 10:58:00
--  
好的,多谢了。
Dim t As Table = CurrentTable
        Dim str As String = CurrentTable.Current("颜色记录")
        Dim ss As String = t.cols(t.ColSel).name
        Dim nstr As String = ""
        For Each s As String In str.split("|")
            
            If s.StartsWith(ss) = False Then
                nstr &= s & "|"
            End If
        Next
        t.Current("颜色记录") = NSTR

那我要是希望框选的所有单元格的颜色都还原呢。。这个应该如何处理呀。

--  作者:有点甜
--  发布时间:2018/9/14 11:28:00
--  
Dim t As Table = CurrentTable
Dim ls As new List(Of String)
For j As Integer = t.LeftCol To t.RightCol
    Dim ss As String = t.cols(j).name
    ls.add(ss)
Next
For i As Integer = t.TopPosition To t.BottomPosition
    Dim r As Row = t.rows(i)
    Dim str As String = r("颜色记录")
    Dim nstr As String = ""
    For Each s As String In str.split("|")
        Dim name = s.Split(":")(0)
        If ls.Contains(name) = False Then
            nstr &= s & "|"
        End If
    Next
    r("颜色记录") = NSTR
Next