Click here to Skip to main content
11,478,642 members (64,646 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hi all,

i've text box and to make that text not to edit but be readable.please reply with an exp
Posted 18-Jan-11 1:19am
ks ravi849
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
set the propery of the text box
ReadOnly=True
i hope this may help you.
  Permalink  
Comments
Espen Harlinn at 18-Jan-11 6:29am
   
5+ Nice and easy answer
Blesson Mathew at 18-Jan-11 6:33am
   
thank you Espen
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Set the readonly property to True.
or paste this code on your form:
//private void Form1_Load(object sender, EventArgs e)
//{
    textBox1.ReadOnly = true;
//}
  Permalink  
Comments
Espen Harlinn at 18-Jan-11 6:30am
   
5+ Nice and easy answer
Аslam Iqbal at 18-Jan-11 6:33am
   
Thanks Harlinn
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

You can use the Readonly or Enabled property of Textbox for this purpose

txtBox1.ReadOnly=true;
-or -
txtBox1.Enabled=false;

You can set this from the Design level also
  Permalink  
Comments
Espen Harlinn at 18-Jan-11 6:32am
   
5+ Nice and easy answer, choose the approach that gives the right clue to the user.
Priyanka Bhagwat at 5-Sep-13 1:02am
   
5+ this is the easiest and best approach
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

On Page_Load add attribute like:

Textbox1.Attribute.Add("ReadOnly", "ReadOnly")

This will enable the control in read only mode.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

By using read only it will give problems on post back just set this java script property


onkeydown="javascript:return false"



by using this u can have properties like readonly and have absolutely no problem will araise
  Permalink  

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 209
1 F-ES Sitecore 170
2 Frankie-C 120
3 OriginalGriff 105
4 DamithSL 95
0 Sergey Alexandrovich Kryukov 7,865
1 OriginalGriff 7,341
2 Sascha Lefèvre 3,059
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 5 Sep 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