[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

MSHflexgrid and copying contents to the clipboard

This may be a simplistic question, and it may be answered already, but I can't seem to get the search results to come up with any results.

I need a quick and easy way to copy the user selected portion of a MSHflexgrid to the clipboard.

Any takers?
0
edwinson
Asked:
edwinson
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
Something like this:

        With mshfgMB
            'Select all data
            .Row = 0
            .Col = 0
            .RowSel = .Rows - 1
            .ColSel = .Cols - 1
            Clipboard.SetText .Clip
        End With
0
 
TimCotteeCommented:
Private Sub grdTrends_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = vbRightButton Then
        If MsgBox("Copy Selected Cells To Clipboard?", vbExclamation + vbYesNo) = vbYes Then
            With grdTrends
                If .Col <= .ColSel Then
                    intColStart = .Col
                    intColEnd = .ColSel
                Else
                    intColStart = .ColSel
                    intColEnd = .Col
                End If
                If .Row <= .RowSel Then
                    intRowStart = .Row
                    intRowEnd = .RowSel
                Else
                    intRowStart = .RowSel
                    intRowEnd = .Row
                End If
                strText = ""
                For intRow = intRowStart To intRowEnd
                    For intcol = intColStart To intColEnd
                        strText = strText & .TextMatrix(intRow, intcol) & IIf(intcol < intColEnd, vbTab, vbCrLf)
                    Next
                Next
                Clipboard.Clear
                Clipboard.SetText strText
            End With
        End If
    End If
End Sub
0
 
Éric MoreauSenior .Net ConsultantCommented:
Any news edwinson?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now