找回密码
 立即注册

QQ登录

只需一步,快速开始

sansanhw

初级会员

36

主题

70

帖子

228

积分

初级会员

积分
228
sansanhw
初级会员   /  发表于:2021-2-28 10:51  /   查看:3052  /  回复:5
1金币
如题

5 个回复

倒序浏览
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-2-28 21:11:33
沙发
参考如下的代码设置即可

flexgrid1.getcellrange(1,1).stylenew.forecolor
回复 使用道具 举报
sansanhw
初级会员   /  发表于:2021-3-1 20:39:26
板凳
wpf没有这个方法的吧
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-3-2 09:32:21
地板
抱歉没有看清楚你的开发平台,WPF中稍微麻烦一些,需要自定义一个CellFectory,具体代码如下


  1. //加载时设置
  2. grid.CellFactory = new MyCellFactory();

  3.         public class MyCellFactory : CellFactory
  4.         {
  5.             public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange rng, Border bdr)
  6.             {
  7.                 var columnindex = rng.Column;
  8.                 var rowindex = rng.Row;
  9.                 if ((columnindex == 2) && (rowindex == 3))
  10.                 {
  11.                     // set the customizations on the cell when it is not selected   
  12.                     bdr.Background = new SolidColorBrush(Colors.Red);
  13.                     bdr.BorderBrush = Brushes.Blue;
  14.                     bdr.BorderThickness = new Thickness(1);
  15.                 }
  16.             }
  17.         }
复制代码

回复 使用道具 举报
sansanhw
初级会员   /  发表于:2021-3-19 10:14:03
5#
这个是设置背景颜色,我需要设置数据字体颜色
回复 使用道具 举报
Richard.Ma讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2021-3-19 11:49:32
6#
可以稍作修改,在非编辑状态,默认的是一个textblack,设置其foregound即可

  1.         public class MyCellFactory : CellFactory
  2.         {
  3.             public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange rng, Border bdr)
  4.             {
  5.                 var columnindex = rng.Column;
  6.                 var rowindex = rng.Row;
  7.                 if ((columnindex == 2) && (rowindex == 3))
  8.                 {
  9.                     if(bdr.Child is TextBlock)
  10.                     {
  11.                         (bdr.Child as TextBlock).Foreground = new SolidColorBrush(Colors.Red);
  12.                     }
  13.                     
  14.                     // set the customizations on the cell when it is not selected   
  15.                     
  16.                     bdr.BorderBrush = Brushes.Blue;
  17.                     bdr.BorderThickness = new Thickness(1);
  18.                 }
  19.             }
  20.         }
复制代码
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部