以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- [求助]按条件实现表格填充样式? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=122192)
|
-- 作者:ufo20085
-- 发布时间:2018/7/20 14:17:00
-- [求助]按条件实现表格填充样式?
此主题相关图片如下:捕获2.png
![dvubb 图片点击可在新窗口打开查看](UploadFile/2018-7/2018720148412728.png)
老师您好,我现在工作中要做一个同品商品名异商品编码的分析。基础数据排序后如图所示。 为方便查看想实现如下功能: 有一个按钮,按一下以后,从当前行开始向下分析,第一种商品里的第一种商品编码填充样式1,第二种商品编码填充样式2,……,第n种商品编码填充样式n。 再按一下,开始分析第二种商品。 以图所示,第一下按,1-4行的商品编码列填充红色,第5行商品编码列填充绿色; 第二下按,6-7行的商品编码列填充红色,8-9行填充绿色; 第三下按,10行红色,11-12行绿色。
|
-- 作者:有点甜
-- 发布时间:2018/7/20 14:24:00
--
1、参考 http://www.foxtable.com/webhelp/scr/0656.htm
2、你的逻辑是什么?临时设置样式,参考
Dim t As Table = Tables("表A") Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1") cs1.backcolor = Color.red cs1.Border.Direction = 2 t.Grid.SetCellStyle(1, 1, cs1) t.Grid.SetCellStyle(2, 1, cs1)
|
-- 作者:ufo20085
-- 发布时间:2018/7/20 14:34:00
--
以下是引用有点甜在2018/7/20 14:24:00的发言:
1、参考 http://www.foxtable.com/webhelp/scr/0656.htm
2、你的逻辑是什么?临时设置样式,参考
Dim t As Table = Tables("表A") Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1") cs1.backcolor = Color.red cs1.Border.Direction = 2 t.Grid.SetCellStyle(1, 1, cs1) t.Grid.SetCellStyle(2, 1, cs1)
老师,设置样式这些代码帮助里有,我会写。 逻辑是这样。。。同一种商品名称,有不同的商品编码,那么可能商品编码是有错的。。 比如第一种商品红茶,前4条是第一种商品编码,第5条是第二种商品编码。 我想实现的功能,是每次只分析并标注一种商品里的不同编码。。。 把同一种商品的不同编码填充不同的颜色。 再按一下按钮,分析标注下一个商品的不同编码
|
-- 作者:有点甜
-- 发布时间:2018/7/20 14:50:00
--
Dim t As Table = Tables("表A") Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1") cs1.backcolor = Color.red Dim cs2 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式2") cs2.backcolor = Color.green
For i As Integer = t.Position To t.Rows.count-1 If i <> t.Position Then If t.Rows(i)("第二列") <> t.Rows(i-1)("第二列") Then t.position = i Exit For End If If t.Rows(i)("第一列") <> t.Rows(i-1)("第一列") Then t.Grid.SetCellStyle(i+1, 1, cs2) Else t.Grid.SetCellStyle(i+1, 1, cs1) End If Else t.Grid.SetCellStyle(i+1, 1, cs1) End If Next
|
-- 作者:ufo20085
-- 发布时间:2018/7/20 15:48:00
--
老师您好,按您的代码,有一个bug,请您测试,先按排序,再按分析。。以J1不锈钢卷板为例,7219340000同一编码却被标注为不同的颜色。。
还有一个功能需添加。。就是当分析下一项商品时,刚刚上一项商品填充的颜色清空。。。就是只标注当前的商品。。
|
-- 作者:ufo20085
-- 发布时间:2018/7/20 15:49:00
--
![dvubb 图片点击可在新窗口打开查看](skins/default/filetype/png.gif) 此主题相关图片如下:捕获3.png ![dvubb 图片点击可在新窗口打开查看](UploadFile/2018-7/201872015483497765.png)
|
-- 作者:ufo20085
-- 发布时间:2018/7/20 15:50:00
--
请老师帮忙测试
|
-- 作者:有点甜
-- 发布时间:2018/7/20 16:19:00
--
先点击排序,再分析
Dim t As Table = Tables("同品名异归类") Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1") cs1.backcolor = Color.red Dim cs2 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式2") cs2.backcolor = Color.green Dim idx = t.grid.Cols("商品编码").Index For i As Integer = t.Position To t.Rows.count-1 If i <> t.Position Then If t.Rows(i)("商品名称") <> t.Rows(i-1)("商品名称") Then t.position = i Exit For End If If t.Rows(i)("商品编码") <> t.Rows(i-1)("商品编码") Then t.Grid.SetCellStyle(i+1, idx, cs2) Else t.Grid.SetCellStyle(i+1, idx, cs1) End If Else t.Grid.SetCellStyle(i+1, idx, cs1) End If Next
|
-- 作者:ufo20085
-- 发布时间:2018/7/20 16:20:00
--
以下是引用有点甜在2018/7/20 14:50:00的发言:
Dim t As Table = Tables("表A") Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1") cs1.backcolor = Color.red Dim cs2 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式2") cs2.backcolor = Color.green
For i As Integer = t.Position To t.Rows.count-1 If i <> t.Position Then If t.Rows(i)("第二列") <> t.Rows(i-1)("第二列") Then t.position = i Exit For End If If t.Rows(i)("第一列") <> t.Rows(i-1)("第一列") Then t.Grid.SetCellStyle(i+1, 1, cs2) Else t.Grid.SetCellStyle(i+1, 1, cs1) End If Else t.Grid.SetCellStyle(i+1, 1, cs1) End If Next
请老师测试bug
|
-- 作者:有点甜
-- 发布时间:2018/7/20 16:28:00
--
先点击排序,再分析
Dim t As Table = Tables("同品名异归类") Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1") cs1.backcolor = Color.red Dim cs2 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式2") cs2.backcolor = Color.green Dim idx = t.grid.Cols("商品编码").Index For i As Integer = t.Position To t.Rows.count-1 If i <> t.Position Then If t.Rows(i)("商品名称") <> t.Rows(i-1)("商品名称") Then t.position = i Exit For End If If t.Rows(i)("商品编码") <> t.Rows(i-1)("商品编码") Then t.Grid.SetCellStyle(i+1, idx, cs2) Else t.Grid.SetCellStyle(i+1, idx, cs1) End If Else t.Grid.SetCellStyle(i+1, idx, cs1) End If Next
|