Error When Trying to copy a row from a datagrid

B

bidalah

Hi,

I have a vb.net windows form with a datagrid, and I am simply trying
to click on a row, hit CTRL-C to copy and then CTRL-P to paste it
somewhere else. This works fine for individual cells. When I try it
with an entire row however, I get the following error:

DataGridColumnStyle of '' cannot be used because it is not associated
with a Property or Column in the DataSource.

This error occurs as soon as I hit CTRL-C. Strangely the unhandled
exception occurs at the definition of the parent form ("Public Class
Mainform"), even though the datagrid is located on a child form.

Does anyone know what is going on. I want to be able to copy and
paste whole rows, but even if I can't, I really can't have the users
getting unhandled errors for trying.

Anyone seen this before?
 
J

justin creasy

Hi,

I have a vb.net windows form with a datagrid, and I am simply trying
to click on a row, hit CTRL-C to copy and then CTRL-P to paste it
somewhere else. This works fine for individual cells. When I try it
with an entire row however, I get the following error:

DataGridColumnStyle of '' cannot be used because it is not associated
with a Property or Column in the DataSource.

This error occurs as soon as I hit CTRL-C. Strangely the unhandled
exception occurs at the definition of the parent form ("Public Class
Mainform"), even though the datagrid is located on a child form.

Does anyone know what is going on. I want to be able to copy and
paste whole rows, but even if I can't, I really can't have the users
getting unhandled errors for trying.

Anyone seen this before?

When you say "datagrid" are you referring to the DataGridView Control
in .NET? I made a quick project in VS 2005 C# and added a DataGridView
control to my WinForm. It handles Ctrl+C commands just fine. Could you
put more of your code here, especially any code where you modify the
way the DataGridView works?

Once you are able to get the error to stop occurring you press Ctrl+C
you might want to check out this article to learn how to access the
GetClipboardContent property from a DataGridView.

http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.getclipboardcontent.aspx
 

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