请问VB怎么实现MSHFlexGrid支持ctrl+c、ctrl+v

解决方案 »

  1.   

    Private Sub MSHFlexGrid1_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim tmptext As String
    If Shift = 2 Then
        Select Case KeyCode
            Case vbKeyC
                Clipboard.Clear
                Clipboard.SetText MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, MSHFlexGrid1.Col)
            Case vbKeyV
                If Clipboard.GetFormat(vbCFText) Then
                tmptext = Clipboard.GetText(vbCFText)
                MSHFlexGrid1.TextMatrix(MSHFlexGrid1.Row, MSHFlexGrid1.Col) = tmptext ' Clipboard.GetData()
                End If
        End Select
    End If
    End Sub
      

  2.   

    你是要复制粘贴什么呢?
    如果按ctrl+c时,把你grid中选定的行列进行复制这样好说的,
    你可以描述当前选的内容,将他形成带分隔符的字符串,使用chr(9)表示列分隔符chr(13)chr(10)表示行分隔这样的格式,然后送入clipboard!
    同理,你ctrl+v时,先从clipboard读出来然后按上面的格式分析读出的内容并写入grid中不就行了么?
      

  3.   

    如果需要复制区域
    Clipboard.Clear
    Clipboard.SetText MSHFlexGrid1.Clip
      

  4.   


    Clipboard.Clear
    Clipboard.SetText MSHFlexGrid1.Clip
      

  5.   

    http://community.csdn.net/Expert/topic/5046/5046735.xml?temp=.1589472