Click here to Skip to main content
11,496,146 members (604 online)
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.
See more: C# ADO.NET WinForm
I have a DataGridView with Readonly textbox column, i want to restrict from pasting into column.

thx in advance
Posted 5-Jul-13 7:32am
CHill60 at 5-Jul-13 13:38pm
Surely if you've made the column read-only then no-one can paste anything into it?
Set text box read only property on grid view row data bound column this way user can't enter into text box.
If not solve your problem paste you code here.

Use this code on row data bound:

private void textBox1_KeyDown(object sender, KeyEventArgs e)
if (e.Modifiers == Keys.Control)
e.Handled = true;
textBox1.SelectionLength = 0;


private void textBox1_KeyDown(object sender, KeyEventArgs e)
            if (e.Control == true)
                MessageBox.Show("Cut/Copy and Paste Options are disabled");

Accept as answer and vote if solve your problem.
Ravi Sargam at 5-Jul-13 14:22pm
It is editable textbox column
Ravi Sargam at 5-Jul-13 14:36pm
i am using it on windows form
jaideepsinh at 5-Jul-13 14:46pm
Check my solution i have updated.
Ravi Sargam at 5-Jul-13 15:07pm
Thx a lot jai, its working...
jaideepsinh at 8-Jul-13 1:03am
Please dear accept as answer if solve your problem.

<asp:textbox id="yourControlId" runat="server" oncopy="return false" onpaste="return false" oncut="return false" ondelete="return false" xmlns:asp="#unknown">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 10,401
1 OriginalGriff 8,910
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 5 Jul 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100