datagridview copy and paste

T

The Tarm

Hi everyone,
I found resources on the web to do a copy on a datagridview control but i
havent found any on pasting back to the control. I m trying to figure out
how to do a shallow copy on a datagrid row.
if (c is DataGridView)

{

DataGridView d = (DataGridView)c;

Clipboard.SetDataObject(d.GetClipboardContent());

}


Can someone please point me out to resources on how to paste cells copied
this way into the datagrid. Links or pointers will be appreciated.

- idatarm
 
N

Nicholas Paldino [.NET/C# MVP]

The Tarm,

Doing so would be very difficult. You would have to basically figure
out when you want the paste operation to occur, and then parse the
information from the clipboard into a two-dimensional array of values. Once
you have that, you would have to traverse the cells and paste the values
into the cells.

You might want to consider overriding the GetClipboardContent and
placing the information on the clipboard which is easier to figure out the
values of, as right now, you are getting a comma delimited file, html, and
text.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top