以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助] 单元格边框为什么只有右边和下边显示?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=77199)

--  作者:lsy
--  发布时间:2015/11/12 16:56:00
--  [求助] 单元格边框为什么只有右边和下边显示?
Dim t As Table = Tables("表A")
Dim cs As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("自定义样式")
cs.Border.Width = 3
cs.Border.Color = Color.Red
t.Grid.SetCellStyle(t.RowSel + 1,t.ColSel + 1,cs)

如果要设置某一边或所有四边的边框,代码如何写?

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

只能变通

 

Dim t As Table = Tables("表A")
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1")
Dim cs2 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式2")
Dim cs3 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式3")
cs1.Border.Width = 3
cs1.Border.Color = Color.Red
cs1.Border.Direction = 0
cs2.Border.Width = 3
cs2.Border.Color = Color.Red
cs2.Border.Direction = 1
cs3.Border.Width = 3
cs3.Border.Color = Color.Red
cs3.Border.Direction = 2
t.Grid.SetCellStyle(t.RowSel + 1,t.ColSel + 1,cs1)
t.Grid.SetCellStyle(t.RowSel,t.ColSel + 1,cs2)
t.Grid.SetCellStyle(t.RowSel + 1,t.ColSel,cs3)


--  作者:lsy
--  发布时间:2015/11/12 17:22:00
--  
能达到目的就行。
谢谢!

--  作者:lhlh
--  发布时间:2016/8/20 12:29:00
--  

上面的例子,要实现之前选择的单元格边框恢复原貌,而新点击的单位格边框显示红色,选择其他控件后,整个表格恢复原貌。


--  作者:Hyphen
--  发布时间:2016/8/20 13:39:00
--  
看懂2楼的代码

在BeforeSelChange事件还原之前选择单元格的样式

--  作者:lhlh
--  发布时间:2016/8/20 14:30:00
--  
以下是引用Hyphen在2016/8/20 13:39:00的发言:
看懂2楼的代码

在BeforeSelChange事件还原之前选择单元格的样式

 

麻烦帮看一下,我只是将颜色改为白色,但不行,所有单击过的单元格还是保持红色,不知怎么不原?

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目3.zip


--  作者:Hyphen
--  发布时间:2016/8/20 14:36:00
--  
BeforeSelChange事件

Dim t As Table = e.Table
t.Grid.Styles.remove("样式1")
t.Grid.Styles.remove("样式2")
t.Grid.Styles.remove("样式3")


--  作者:lhlh
--  发布时间:2016/8/20 14:45:00
--  
成了,真是好人呀,谢谢!
--  作者:lhlh
--  发布时间:2016/8/20 16:42:00
--  

有个问题,如下图箭头所示地方,怎么两条边条会不显示?用的就是如下代码

Dim t As Table = Tables("表A")
Dim cs1 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式1")
Dim cs2 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式2")
Dim cs3 As C1.Win.C1FlexGrid.CellStyle = t.Grid.Styles.Add("样式3")
cs1.Border.Width = 3
cs1.Border.Color = Color.Red
cs1.Border.Direction = 0
cs2.Border.Width = 3
cs2.Border.Color = Color.Red
cs2.Border.Direction = 1
cs3.Border.Width = 3
cs3.Border.Color = Color.Red
cs3.Border.Direction = 2
t.Grid.SetCellStyle(t.RowSel + 1,t.ColSel + 1,cs1)
t.Grid.SetCellStyle(t.RowSel,t.ColSel + 1,cs2)
t.Grid.SetCellStyle(t.RowSel + 1,t.ColSel,cs3)

 


图片点击可在新窗口打开查看此主题相关图片如下:20160820163856.png
图片点击可在新窗口打开查看


--  作者:Hyphen
--  发布时间:2016/8/20 17:10:00
--  
这个没有办法。

还是用drawcell做吧

If e.Row.Index = e.Table.RowSel AndAlso e.Col.Index = e.Table.ColSel Then
    using n As New Pen(Color.Red,1)
    e.Graphics.DrawRectangle(n,e.x + 1,e.y + 1,e.Width-4,e.Height-4)
End using
End If