找回密码
 立即注册

QQ登录

只需一步,快速开始

Hjr2350
论坛元老   /  发表于:2013-2-1 14:13  /   查看:6179  /  回复:2
spread 实现EXCEL某些效果这个帖子中第4个问题,当初dof回答我让我使用ComponentOne Studio for WinForms 产品的
C1TEXTBOX
我现在使用了,测试代码如下:

  1.         private void Custom_ToolStripMenuItem_Click(object sender, EventArgs e)
  2.         {
  3.             CTextCellType txt = new CTextCellType();
  4.             fpSpread1.ActiveSheet.Columns[0].CellType = txt;
  5.             fpSpread1.ActiveSheet.Columns[0].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
  6.             fpSpread1.ActiveSheet.Columns[0].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
  7.         }

  8.         public class CTextCellType : FarPoint.Win.Spread.CellType.GeneralCellType
  9.         {

  10.             C1.Win.C1Input.C1TextBox txt = null;
  11.             public CTextCellType()
  12.             {
  13.                 txt = new C1.Win.C1Input.C1TextBox();
  14.                 txt.VerticalAlign = C1.Win.C1Input.VerticalAlignEnum.Middle;
  15.                 txt.TextAlign = HorizontalAlignment.Center;
  16.                 txt.LostFocus += new EventHandler(txt_LostFocus);
  17.             }

  18.             void txt_LostFocus(object sender, EventArgs e)
  19.             {
  20.                 C1.Win.C1Input.C1TextBox txt = sender as C1.Win.C1Input.C1TextBox;
  21.                 txt.Multiline = true;
  22.                 FarPoint.Win.Spread.FpSpread spread = txt.Parent as FarPoint.Win.Spread.FpSpread;
  23.                 spread.ActiveSheet.ActiveCell.Value = txt.Text;
  24.             }

  25.             public override Control GetEditorControl(Control parent, FarPoint.Win.Spread.Appearance appearance, float zoomFactor)
  26.             {
  27.                 return txt;
  28.             }

  29.             public override object GetEditorValue()
  30.             {
  31.                 return txt.Text;
  32.             }

  33.             public override void SetEditorValue(object value)
  34.             {
  35.                 txt.Value = value;
  36.             }

  37.         }
复制代码

我现在想实现以下两个效果
1.回车时单元格内换行,现在回车,直接跳到另一个单元格
2.如何设置单元格内的行间距?
由于第一次使用C1TEXTBOX,请各位多多帮助..
谢谢先

2 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2013-2-1 18:35:00
沙发
回复 1楼Hjr2350的帖子

问题一,
通过以下代码,设置 Spread 快捷键行为,再定制 C1TextBox 的 KeyDown 事件,插入换行符:

  1. FarPoint.Win.Spread.InputMap inputmap1=new FarPoint.Win.Spread.InputMap();

  2.             inputmap1.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.None);

  3.             FarPoint.Win.Spread.InputMap inputmap2=new FarPoint.Win.Spread.InputMap();

  4.             inputmap2 = fpSpread1.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);

  5.             inputmap2.Put(new FarPoint.Win.Spread.Keystroke(Keys.Enter, Keys.None), FarPoint.Win.Spread.SpreadActions.None);
复制代码
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2013-2-1 18:43:00
板凳
回复 0楼iceman的帖子

问题二,
Spread Cell 中有多行时,无法设置行间距。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部