找回密码
 立即注册

QQ登录

只需一步,快速开始

chenf1980

论坛元老

41

主题

147

帖子

9349

积分

论坛元老

积分
9349

活字格认证

chenf1980
论坛元老   /  发表于:2011-4-20 15:01  /   查看:9909  /  回复:11
单击某个cell,然后该cell的内容就被选中了。
在一般的textbox里面,有selStart,与selLength方法的。

11 个回复

倒序浏览
robert
金牌服务用户   /  发表于:2011-4-20 16:12:00
沙发
不知道您用的Cell类型是什么?如果是TextBoxCell的话可以使用以下代码
  1. DirectCast(GcMultiRow1(0, 0), TextBoxCell).HighlightText = True
复制代码
回复 使用道具 举报
chenf1980
论坛元老   /  发表于:2011-4-20 16:40:00
板凳
不对,我用的textboxcell,没有HighlightText这个属性的。
回复 使用道具 举报
chenf1980
论坛元老   /  发表于:2011-4-20 16:46:00
地板
我的multirow是5.0版本的
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2011-4-20 17:20:00
5#
哦,我以为你是用的6.0呢,这个属性是6.0新加的,不好意思。
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2011-4-20 17:27:00
6#
在5.0中实现这个功能比较复杂需要重写TextBoxCell。
  1. Class MyTextBoxCell
  2.     Inherits TextBoxCell
  3.     Public Overrides ReadOnly Property EditType As System.Type
  4.         Get
  5.             Return GetType(MyTextBoxEditingControl)
  6.         End Get
  7.     End Property
  8. End Class
  9. Class MyTextBoxEditingControl
  10.     Inherits TextBoxEditingControl
  11.     Public Overrides Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean)
  12.         MyBase.PrepareEditingControlForEdit(True)
  13.     End Sub
  14. End Class
复制代码
回复 使用道具 举报
chenf1980
论坛元老   /  发表于:2011-4-20 17:39:00
7#
恩,如果需要传入一个参数,true跟false的话,true的情况下被选中,那么应该怎么传入呢?
回复 使用道具 举报
robert
金牌服务用户   /  发表于:2011-4-21 09:30:00
8#
给MyTextBoxCell类添加一个HighlightText属性,通过设置这个属性来控制是否全选Text
代码如下:
  1. Class MyTextBoxCell
  2.     Inherits TextBoxCell
  3.     Public HighlightText As Boolean = True
  4.     Public Overrides ReadOnly Property EditType As System.Type
  5.         Get
  6.             Return GetType(MyTextBoxEditingControl)
  7.         End Get
  8.     End Property
  9.     Protected Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, ByVal formattedValue As Object, ByVal style As GrapeCity.Win.MultiRow.CellStyle)
  10.         MyBase.InitializeEditingControl(rowIndex, formattedValue, style)
  11.         DirectCast(Me.GcMultiRow.EditingControl, MyTextBoxEditingControl).HighlightText = HighlightText
  12.     End Sub
  13.     Public Overrides Function Clone() As Object
  14.         Dim myCell = DirectCast(MyBase.Clone(), MyTextBoxCell)
  15.         myCell.HighlightText = Me.HighlightText
  16.         Return myCell
  17.     End Function
  18. End Class
  19. Class MyTextBoxEditingControl
  20.     Inherits TextBoxEditingControl
  21.     Public HighlightText As Boolean
  22.     Public Overrides Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean)
  23.         MyBase.PrepareEditingControlForEdit(HighlightText)
  24.     End Sub
  25. End Class
复制代码
回复 使用道具 举报
chenf1980
论坛元老   /  发表于:2011-4-29 16:36:00
9#
不好意思,按照这样写的话,我发现了一个问题。内容是被选中了,但是不触发cellclick事件了哦。该单元格是可编辑的。
回复 使用道具 举报
chenf1980
论坛元老   /  发表于:2011-4-29 16:47:00
10#
又要麻烦版主你了
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部