找回密码
 立即注册

QQ登录

只需一步,快速开始

czpi

高级会员

24

主题

44

帖子

1876

积分

高级会员

积分
1876

活字格认证

czpi
高级会员   /  发表于:2014-9-5 09:20  /   查看:4523  /  回复:1
版本:Spread for Windows Form 7.0J

把单元格设置成 DateTimeCellType
UserDefineFoamat设置成 "yy/MM"

通过Calender或者手动入力2014年9月份的某一天,单元格显示"14/09",点击某个按钮,可以取到该单元格的Text值,例如:"14/09",一切正常。

但是,在Spread控件的Leave事件里面,却取不到单元格的.Text值,.Value值是存在的,.Text值却是空。

请问,怎样才能在Spread控件的Leave事件里面,能够取到Text值?

1 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-9-5 16:24:00
沙发
回复 1楼czpi的帖子

你好,
通过以下代码我这边是可以取到的,请测试:

  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             FarPoint.Win.Spread.CellType.DateTimeCellType dt = new FarPoint.Win.Spread.CellType.DateTimeCellType();
  4.             dt.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined;
  5.             dt.UserDefinedFormat = "yy/MM";
  6.             fpSpread1.ActiveSheet.Cells[0, 0].CellType = dt;

  7.             fpSpread1.Leave += fpSpread1_Leave;
  8.         }

  9.         void fpSpread1_Leave(object sender, EventArgs e)
  10.         {
  11.             MessageBox.Show(fpSpread1.ActiveSheet.Cells[0, 0].Text);
  12.         }

复制代码

谢谢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部