找回密码
 立即注册

QQ登录

只需一步,快速开始

chenf1980

论坛元老

41

主题

147

帖子

9349

积分

论坛元老

积分
9349

活字格认证

chenf1980
论坛元老   /  发表于:2011-5-17 15:19  /   查看:5703  /  回复:3
设置了textboxcell的format为##-##-##,这样的话,输入111111后,就变成了11-11-11,但是我想实现,对该boxcell进行编辑的时候,鼠标放进去了,显示为111111,当失去焦点后才变成 11-11-11,请问该如何实现

3 个回复

倒序浏览
neil
论坛元老   /  发表于:2011-5-17 17:00:00
沙发
目前的表现是基于微软标准的formatting策略的。

如果你想要在再次进入Cell的时候,依然显示111111,  需要处理GcMultiRow的EditingControlShowing事件,  在事件中,把e.Control.Text设为当前Cell的Value。

实现代码:
C# 代码:

  1. private void gcMultiRow1_EditingControlShowing(object sender, GrapeCity.Win.MultiRow.EditingControlShowingEventArgs e)
  2.         {

  3.             CellPosition currentCell = this.gcMultiRow1.CurrentCellPosition;

  4.             //这里可能需要判断currentCell.CellIndex是不是你想处理的那一列cell。
  5.             //if ()
  6.             {
  7.                 object value = this.gcMultiRow1.GetValue(currentCell.RowIndex, currentCell.CellIndex);
  8.                 if (value != null)
  9.                 {
  10.                     e.Control.Text = value.ToString();
  11.                 }
  12.             }            
  13.         }
复制代码
VB 代码:
  1. Private Sub gcMultiRow1_EditingControlShowing(sender As Object, e As GrapeCity.Win.MultiRow.EditingControlShowingEventArgs)

  2.         Dim currentCell As CellPosition = Me.gcMultiRow1.CurrentCellPosition

  3.         '这里可能需要判断currentCell.CellIndex是不是你想处理的那一列cell。
  4.         'if ()
  5.         ‘ Then
  6.                 Dim value As Object = Me.gcMultiRow1.GetValue(currentCell.RowIndex, currentCell.CellIndex)

  7.                 If value IsNot Nothing Then
  8.                         e.Control.Text = value.ToString()
  9.                 End If
  10.         ’End If
  11. End Sub
复制代码
回复 使用道具 举报
chenf1980
论坛元老   /  发表于:2011-5-17 17:20:00
板凳
很好用,谢谢
回复 使用道具 举报
neil
论坛元老   /  发表于:2011-5-18 08:56:00
地板
不客气。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部