以文本方式查看主题

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

--  作者:zhangqinyun
--  发布时间:2011/9/8 13:56:00
--  [求助]如何用颜色标记一列??

我在编写排产表

要把今天的列用颜色标记出来,怎么标记。

 

我知道标记列标题:

Tables("排产表").SetHeaderCellBackColor("D0",Color.Yellow,1)

 

但不知道怎么标记一整列,难道:

For I = 1 to Tables("排产表").Count

Tables("排产表").SetHeaderCellBackColor("D0",Color.Yellow,1)

Next

这样??

 

有没有简单的啊,我要标记好几列。


--  作者:狐狸爸爸
--  发布时间:2011/9/8 14:12:00
--  

参考:

 

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

 


--  作者:zhangqinyun
--  发布时间:2011/9/8 14:20:00
--  

我的排产表是临时表啊!

\'排产表
Dim Td As Date = Date.Today
Dim Name As String
Dim I As Short
Dim dtb As New DataTableBuilder("排产表")
dtb.AddDef("生产组", Gettype(String), 4)
dtb.AddDef("产品编号", Gettype(String), 12)
dtb.AddDef("令号", Gettype(String), 6)
For I = -3 To 0
    dtb.AddDef("D" & I, Gettype(Integer))
    dtb.AddDef("S" & I, Gettype(Integer))
Next
For I = 1 To 14
    dtb.AddDef("D" & I, Gettype(Integer))
Next
dtb.Build()
Tables("排产表").StopRedraw
\'调整列宽
With Tables("排产表")
    .Cols("生产组").Width = 40
    .Cols("产品编号").Width = 70
    .Cols("令号").Width = 45
    For I = -3 To 14
        .Cols("D" & I).Width = 40
    Next
    For I = -3 To 0
        .Cols("S" & I).Width = 40
    Next
End With
\'重写列标题
Dim Cap As String
Dim ThatD As Date
For I = -3 To 14
    ThatD = Td.AddDays(I)
    If ThatD.DayOfWeek = 0 Then
        Cap = "休息"
    Else
        Cap = ThatD.Day & "日"
    End If
    DataTables("排产表").DataCols("D" & I).Caption = ThatD.Year & "年" & ThatD.Month & "月" & "_" & Cap
Next
For I = -3 To 0
    ThatD = Td.AddDays(I)
    Cap = ThatD.Day & "实"  
    DataTables("排产表").DataCols("S" & I).Caption = ThatD.Year & "年" & ThatD.Month & "月" & "_" & Cap
Next
DataTables("排产表").BuildHeader()
\'颜色标记
For I = -3 To -1
    Tables("排产表").SetHeaderCellBackColor("D" & I,Color.Red,1)
Next
Tables("排产表").SetHeaderCellBackColor("D0",Color.Yellow,1)
Tables("排产表").ResumeRedraw


--  作者:zhangqinyun
--  发布时间:2011/9/8 14:21:00
--  
上面的只有列标题标记颜色!
--  作者:狐狸爸爸
--  发布时间:2011/9/8 14:41:00
--  
二楼有答案,您先看一下,有问题再提问吧。
--  作者:zhangqinyun
--  发布时间:2011/9/8 14:51:00
--  

临时表没有DrawCell~ ~b

自己搞定了,,虽然代码很繁琐

\'颜色标记
N = Plans.Count
For I = -3 To -1
    For I1 = 2 To N
        Tables("排产表").SetHeaderCellBackColor("D" & I,Color.Red,I1)
    Next
Next
For I = -3 To -0
    For I1 = 2 To N
        Tables("排产表").SetHeaderCellBackColor("S" & I,Color.Green,I1)
    Next
Next
For I1 = 2 To N
    Tables("排产表").SetHeaderCellBackColor("D0",Color.Yellow,I1)
Next


--  作者:yangming
--  发布时间:2011/9/8 14:57:00
--  
setHeaderCellBackColor,这就是标题的背景色,呵
--  作者:zhangqinyun
--  发布时间:2011/9/8 15:12:00
--  

也可以标记表里面的内容的啊.呵呵


--  作者:紙上不談兵
--  发布时间:2011/9/8 15:31:00
--  
以下是引用zhangqinyun在2011-9-8 15:12:00的发言:

也可以标记表里面的内容的啊.呵呵

-------------------------------------------------------------------------------------

高!这都给你试出来.这样一来,就很容易有条件地标记数据了


Dim t as Table = Tables("订单")
For I As Integer = 1 To t.Rows.count
    Dim r As Row =t .Rows(i-1)
    If r("单价") > 50 Then
        t.SetHeaderCellBackColor("单价",Color.Red,I)
    End If
Next


--  作者:紙上不談兵
--  发布时间:2011/9/8 15:34:00
--  

SetHeaderCellBackColor

设置指定列的标题的背景颜色呀。


老大,这又是意外之喜吧!