junlingzhu2002 发表于 2012-8-31 12:38:00

MultiRow的Cell的SelectionStart

怎样取得输入的数字在TextBoxCell.Text的位置
如果是TextBox可以用SelectionStart

wedy.wang 发表于 2012-8-31 15:47:00

请参考下面的代码:


void Form1_Load(object sender, EventArgs e)
      {
            this.gcMultiRow1.EditingControlShowing += gcMultiRow1_EditingControlShowing;
      }

      void gcMultiRow1_EditingControlShowing(object sender, EditingControlShowingEventArgs e)
      {
            TextBox textBox = e.Control as TextBox;
            if (textBox != null)
            {
                var selectionStart = textBox.SelectionStart;
            }
      }

junlingzhu2002 发表于 2012-9-6 09:51:00

不好意思,
我用的是VB.NET,可以在从新发个给我吗

wedy.wang 发表于 2012-9-6 14:25:00

回复 3楼junlingzhu2002的帖子

你想在什么时机获取这些属性?
你可以在GcMultiRow的EditingControlShowing事件里面首先拿到e.Control, 将它转换为TextBox,然后再挂TextBox的相关事件,来获取你想要的这几个属性(SelectionStart,SelectionLength)。
Public Class Form1
    Private Sub GcMultiRow1_EditingControlShowing(sender As Object, e As EditingControlShowingEventArgs) Handles GcMultiRow1.EditingControlShowing
      Dim textBox As TextBox = TryCast(e.Control, TextBox)
      If textBox IsNot Nothing Then
            AddHandler textBox.TextChanged, New EventHandler(AddressOf Me.TextBox_TextChanged)
      End If
    End Sub

    Private Sub TextBox_TextChanged(sender As Object, e As EventArgs)
      Dim textBox As TextBox = TryCast(sender, TextBox)
      Dim selectionStart = textBox.SelectionStart
      Dim selectionLength = textBox.SelectionLength
    End Sub
End Class

junlingzhu2002 发表于 2012-9-11 12:47:00

谢谢
页: [1]
查看完整版本: MultiRow的Cell的SelectionStart