在光标位置datagridview插入字符?

时间:2014-06-18 09:15:27

标签: vb.net datagridview

当我按下F9,光标可能在任何位置时,如何在datagridview单元格的鼠标光标位置插入字符GG?

1 个答案:

答案 0 :(得分:0)

Dim c As Control = Me.dgvDetail.EditingControl 
If c IsNot Nothing AndAlso TypeOf c Is TextBox Then
   selectionStart = CType(c, TextBox).SelectionStart 
End If Dim text As String = CStr(Me.dgvDetail.CurrentCell.Value)
Me.dgvDetail.CurrentCell.Value = text.Insert(selectionStart, "GG")