Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Controls / October 2005

Tip: Looking for answers? Try searching our database.

Copy/Paste from Datagridview

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Glen - 28 Oct 2005 16:42 GMT
Can anyone point me to an article/example of how to do a copy from a
datagridview?

I have a datagridview in which a user can select a block of cells (not
necessarily complete rows).  I would like them to be able to copy this
info by either a right-click (context menu) or CTL-C.

Any help would be greatly appreciated.

Sincerely,
Glen
Glen - 28 Oct 2005 19:57 GMT
Stumbled across the solution.  Too easy...

   Private Sub mnuCopy_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles mnuCopy.Click

       If Me.SelectedCells.Count <= 0 Then Exit Sub

       If MessageBox.Show("Do you want to copy the header titles as
well?", "Header Titles", MessageBoxButtons.YesNo,
MessageBoxIcon.Question) = DialogResult.Yes Then
           Me.ClipboardCopyMode =
DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText
       Else
           Me.ClipboardCopyMode =
DataGridViewClipboardCopyMode.EnableWithoutHeaderText
       End If

       Clipboard.SetDataObject(Me.GetClipboardContent())

   End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.