如何定义flexgrid指定单元格字体的颜色
如题参考如下的代码设置即可
flexgrid1.getcellrange(1,1).stylenew.forecolor wpf没有这个方法的吧 抱歉没有看清楚你的开发平台,WPF中稍微麻烦一些,需要自定义一个CellFectory,具体代码如下
//加载时设置
grid.CellFactory = new MyCellFactory();
public class MyCellFactory : CellFactory
{
public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange rng, Border bdr)
{
var columnindex = rng.Column;
var rowindex = rng.Row;
if ((columnindex == 2) && (rowindex == 3))
{
// set the customizations on the cell when it is not selected
bdr.Background = new SolidColorBrush(Colors.Red);
bdr.BorderBrush = Brushes.Blue;
bdr.BorderThickness = new Thickness(1);
}
}
}
这个是设置背景颜色,我需要设置数据字体颜色 可以稍作修改,在非编辑状态,默认的是一个textblack,设置其foregound即可
public class MyCellFactory : CellFactory
{
public override void ApplyCellStyles(C1FlexGrid grid, CellType cellType, CellRange rng, Border bdr)
{
var columnindex = rng.Column;
var rowindex = rng.Row;
if ((columnindex == 2) && (rowindex == 3))
{
if(bdr.Child is TextBlock)
{
(bdr.Child as TextBlock).Foreground = new SolidColorBrush(Colors.Red);
}
// set the customizations on the cell when it is not selected
bdr.BorderBrush = Brushes.Blue;
bdr.BorderThickness = new Thickness(1);
}
}
}
页:
[1]