MultiRow的Cell的SelectionStart
怎样取得输入的数字在TextBoxCell.Text的位置如果是TextBox可以用SelectionStart 请参考下面的代码:
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;
}
}
不好意思,
我用的是VB.NET,可以在从新发个给我吗 回复 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 谢谢
页:
[1]