最终显示的文本完全可以自己来定义,比如通过下面的代码来控制显示的文本:- public class MyCellType : FarPoint.Win.Spread.CellType.GeneralCellType
- {
- public System.Collections.Generic.Dictionary<int, string> Items
- {
- get;
- set;
- }
- public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
- {
- if (value != null)
- {
- value = Items[Convert.ToInt32(value.ToString())];
- }
- base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
- }
- }
复制代码- private void Form1_Load(object sender, EventArgs e)
- {
- MyCellType ctp = new MyCellType();
- Dictionary<int, string> items = new Dictionary<int, string>();
- items.Add(1, "aaaa");
- items.Add(2, "bbbb");
- items.Add(3, "cccc");
- items.Add(4, "dddd");
- items.Add(5, "eeee");
- ctp.Items = items;
- fpSpread1.ActiveSheet.Columns[0].CellType = ctp;
- fpSpread1.ActiveSheet.Cells[0, 0].Value = 3;
- fpSpread1.ActiveSheet.Cells[1, 0].Value = 2;
- fpSpread1.ActiveSheet.Cells[2, 0].Value = 5;
- }
复制代码 |