C# textbox

Hi guys ,

I would like to know how do I provide from my users to type in the textbox (windows form)...the only I need is to display for them information.
LVL 1
Moti Mashiah.NET DeveloperAsked:
Who is Participating?
 
Fernando SotoRetiredCommented:
I see. To do that you can use the ReadOnly property which will allow the user to read the information in the text box but will not allow the user to enter data in to the text box.

TextBoxInstance.ReadOnly = true;

Be advised that doing this will cause the characters to be display as a light gray and some people find it difficult to read. You may want to replace the text box control with a label control which will keep the same text color as the rest of the form and still will not allow the user to change the data.
0
 
Fernando SotoRetiredCommented:
Once you have placed a TextBox control on the form the user is free to type characters into the TextBox. To programmatically get the data from the TextBox and place it into a variable do the following.

string textFromTextBox = textBoxName.Text;

If you wish to programmatically place text into a TextBox then do the following.

TextBoxName.Text = StringVariableInstance;

I hope that answers your question.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
Thank you for your answer but what I want to do is to prevent user from typing into the textbox the textbox display data from the database server.
0
 
Moti Mashiah.NET DeveloperAuthor Commented:
excellent thank you
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.