Solved

Copy to clipboard all DataGridView cells issue

Posted on 2014-11-07
2
136 Views
Last Modified: 2014-11-09
Hi all.

I'm facing another issue with the copy to clipboard functionality

I'm trying to use the below code to copy to clipboard but i get this message: 'SetDataObject' is not a member of 'System.Windows.Form.Button'

How can i fix this.

Thanks

    Private Sub clipboard_Click(sender As Object, e As EventArgs) Handles clipboard.Click
        DataGridView1.SelectAll()
        If DataGridView1.GetClipboardContent Is Nothing Then
            MessageBox.Show("Nothing selected to copy to clipboard.")
        Else
            Me.DataGridView1.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText
            clipboard.SetDataObject(Me.DataGridView1.GetClipboardContent)
        End If
    End Sub

Open in new window

0
Comment
Question by:Wilder1626
2 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40431467
you have named your button clipboard which interferes with calling the "default" Clipboard.

Either rename your button or use full qualification for Clipboard:
System.Windows.Forms.Clipboard.SetDataObject(Me.DataGridView1.GetClipboardContent)

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 40431584
Thank you so much. This is perfect.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question