Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copy to clipboard all DataGridView cells issue

Posted on 2014-11-07
2
Medium Priority
?
146 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 2000 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses

722 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