Solved

Copy to clipboard all DataGridView cells issue

Posted on 2014-11-07
2
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 19 hours left to enroll

626 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