回复 1楼315834729的帖子
请参考以下代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- CTextCellType ctc = new CTextCellType();
- fpSpread1.ActiveSheet.Columns[0].CellType = ctc;
- }
- private class CTextCellType : FarPoint.Win.Spread.CellType.TextCellType
- {
- public override void PaintCell(Graphics g, Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
- {
- if (value != null)
- {
- Font font = appearance.Font;
- while (g.MeasureString(value.ToString(),font).Width >= r.Width && font.Size >= 5)
- {
- font = new Font(font.FontFamily, font.Size - 0.5f, font.Style);
- }
-
- appearance.Font = font;
- }
- base.PaintCell(g, r, appearance, value, isSelected, isLocked, zoomFactor);
- }
- }
复制代码 |