曲线救国啦~~~
Private intKeyStart As IntegerPrivate Sub Form_Load()
    TDBGrid1.DirectionAfterEnter = dbgMoveNone
End SubPrivate Sub TDBGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim strTmp As String
    If KeyCode = 13 Then
        intKeyStart = TDBGrid1.SelStart
        strTmp = TDBGrid1.Columns(TDBGrid1.Col).Text
        strTmp = Left(strTmp, intKeyStart) & vbCrLf & Right(strTmp, Len(strTmp) - intKeyStart)
        TDBGrid1.Columns(TDBGrid1.Col).Text = strTmp
    End If
End SubPrivate Sub TDBGrid1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        TDBGrid1.EditActive = True
        TDBGrid1.SelStart = intKeyStart + 2
        TDBGrid1.SelLength = 0
    End If
End Sub

解决方案 »

  1.   

    我这个方法其实是退出了编辑状态然后立刻又进去,假如你在AfterColedit、BeforeColEdit事件中有处理代码的话,必须加个标志来判断,这个方法用于英文完全没有问题,
    但对于中文我试了一下,问题在于tdbgrid的SelStart属性没有按照unicode来处理,英文算一个字节,中文算两个字节,所以出现插入点有错误。
      

  2.   

    刚刚又试了一下,解决插入点问题是可以,但程序繁了点,你这个问题还是利用一个文本框,定位到单元格上取代tdbgrid自己的单元格编辑功能比较简单。
      

  3.   

    没时间帮你写了,相关的几个属性:
    RowTop、RowHeight、columns(index).left、columns(index).width你自己研究一下吧,程序不难写,可以参考一下tdbgrid自带的教程里面Tutor9,是专门控件定位的例子。