Solved

Copy to clipboard all DataGridView cells issue

Posted on 2014-11-07
2
131 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
Comment Utility
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
Comment Utility
Thank you so much. This is perfect.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now