Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
hi all,

i've text box and to make that text not to edit but be readable.please reply with an exp
Posted

hi,
set the propery of the text box
ReadOnly=True
i hope this may help you.
 
Share this answer
 
Comments
Espen Harlinn 18-Jan-11 6:29am    
5+ Nice and easy answer
Blesson Mathew 18-Jan-11 6:33am    
thank you Espen
Set the readonly property to True.
or paste this code on your form:
C#
//private void Form1_Load(object sender, EventArgs e)
//{
    textBox1.ReadOnly = true;
//}
 
Share this answer
 
Comments
Espen Harlinn 18-Jan-11 6:30am    
5+ Nice and easy answer
Аslam Iqbal 18-Jan-11 6:33am    
Thanks Harlinn
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
 
Share this answer
 
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
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
 
Share this answer
 
Comments
Member 11924880 3-Oct-15 7:03am    
Yes, that's perfect what I wanted....Thanx..
On Page_Load add attribute like:

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

This will enable the control in read only mode.
 
Share this answer
 
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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900