Click here to Skip to main content
12,254,393 members (67,766 online)
Rate this:
 
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 0: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 18-Jan-11 6:29am
   
5+ Nice and easy answer
Blesson Mathew 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 18-Jan-11 6:30am
   
5+ Nice and easy answer
Аslam Iqbal 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 18-Jan-11 6:32am
   
5+ Nice and easy answer, choose the approach that gives the right clue to the user.
Priyanka Bhagwat 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 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  
Comments
Member 11924880 3-Oct-15 7:03am
   
Yes, that's perfect what I wanted....Thanx..
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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 5 Sep 2013
Copyright © CodeProject, 1999-2016
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