回复 4楼moonlight108的帖子
1 Spread提供的默认图标是在数据前面的, 如要修改到后面,请集成IconSetConditionalFormattingRule实现PaintCell 自绘实现。
2 比较的数据,可以不再Spread Sheet里面。
参考代码如下:
- public partial class Form1
- {
- private void InitIcon()
- {
- fpSpread1.Sheets[0].Cells[0, 0].Value = 3;
- fpSpread1.Sheets[0].Cells[1, 0].Value = 2;
- fpSpread1.Sheets[0].Cells[1, 1].Value = 10;
- fpSpread1.Sheets[0].Cells[0, 2].Value = 1;
- // >=10 up icon
- // 5~10 equal icon
- // < 5 down icon
- CellRange celRange1 = new FarPoint.Win.Spread.Model.CellRange(0, 0, 2, 2);
- FarPoint.Win.Spread.IconSetConditionalFormattingRule rule = new MyClass(ConditionalFormattingIconSetStyle.ThreeColoredArrows);
- rule.ShowConditionalFormatOnly = false; // true 仅显示图标
- rule.IconRuleSet.Add(new ConditionalFormattingIconValue(10, ConditionalFormattingValueType.Number, true));
- rule.IconRuleSet.Add(new ConditionalFormattingIconValue(5, ConditionalFormattingValueType.Number, false));
- ConditionalFormatting IconSetCF = new ConditionalFormatting(celRange1, rule);
- fpSpread1.Sheets[0].Models.ConditionalFormatting.Add(IconSetCF);
- }
- }
- public class MyClass : IconSetConditionalFormattingRule
- {
- public MyClass(ConditionalFormattingIconSetStyle iconSetStyle) : base(iconSetStyle) { }
- public override PrePaintTextResult PaintCell(System.Drawing.Graphics g, System.Drawing.Rectangle r, Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
- {
- //图标: this.IconRuleSet[0].Value;
- //条件 this.IconRuleSet[0].Value;
- return base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
- }
- }
复制代码 |