Default Context Menu for DataGridView

J

Joe Cool

I am working on an app that displays some data from a database table
in a DataGridView control. Every colukmn is set to read only and the
user is not allowed to edit the data in the control in any way. I
would like to enable the user to be able to easily copy the data and
paste it into some other application like a text editor. I can select
the rows I want to copy and put the data in the clipboard with Ctrl/C,
but I would like for the user to also be able to do that with the
standard context menu we see a lot that has Undo, Cut, Copy, Paste,
Delete and Select All on it but right clicking anywhere on the control
does not display any context menu. Is there a way to get this back?
 
F

Frank Uray

Hi Joe

You would need to create your own contextmenu,
because standard copy/paste menu does not know
anything about rows ...

Reading/writing to clipboard is easy:
System.Windows.Forms.Clipboard.GetData(System.Windows.Forms.DataFormats.Text)
o
System.Windows.Forms.Clipboard.SetData(System.Windows.Forms.DataFormats.Text, (object)local_Text)

Regards
Frank Uray
 

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