{"id":732,"date":"2011-12-14T16:03:25","date_gmt":"2011-12-14T16:03:25","guid":{"rendered":"https:\/\/ibex.tech\/visualcpp\/?p=732"},"modified":"2022-02-17T06:24:03","modified_gmt":"2022-02-17T06:24:03","slug":"copy-to-clipboard-3","status":"publish","type":"post","link":"https:\/\/ibex.tech\/visualcpp\/datagridview\/copy-to-clipboard-3","title":{"rendered":"Copy To Clipboard"},"content":{"rendered":"<h4>Copy Data Grid View To Clipboard<\/h4>\n<p>Copies as a spreadsheet so it pastes perfectly into Excel and Word<\/p>\n<pre><code>\r\n\t\/\/Set the ClipboardCopyMode property to define if column and row headers should be included\r\n\tdataGridView1-&gt;SelectAll();\r\n\r\n\t\/\/Select by individual cell method:\r\n\t\/\/for (Row = 0; Row &lt; dataGridView1-&gt;RowCount; Row++)\r\n\t\/\/{\r\n\t\/\/\tfor (Column = ; Column &lt; dataGridView1-&gt;Columns-&gt;Count; Column++)\r\n\t\/\/\t\tdataGridView1[Column, Row]-&gt;Selected = true;\r\n\t\/\/}\r\n\r\n\tClipboard::SetDataObject(dataGridView1-&gt;GetClipboardContent());\r\n\r\n\tfor (Row = 0; Row &lt; dataGridView1-&gt;Rows-&gt;Count; Row++)\t\t\t\/\/Deselect all the rows\r\n\t\tdataGridView1-&gt;Rows[Row]-&gt;Selected = false;\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Copy Data Grid View To Clipboard Copies as a spreadsheet so it pastes perfectly into Excel and Word \/\/Set the ClipboardCopyMode property to define if column and row headers should be included dataGridView1-&gt;SelectAll(); \/\/Select by individual cell method: \/\/for (Row = 0; Row &lt; dataGridView1-&gt;RowCount; Row++) \/\/{ \/\/ for (Column = ; Column &lt; dataGridView1-&gt;Columns-&gt;Count; [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-732","post","type-post","status-publish","format-standard","hentry","category-datagridview"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/comments?post=732"}],"version-history":[{"count":3,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/732\/revisions"}],"predecessor-version":[{"id":1034,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/posts\/732\/revisions\/1034"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/media?parent=732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/categories?post=732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/visualcpp\/wp-json\/wp\/v2\/tags?post=732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}