Solved

C# textbox

Posted on 2014-04-11
4
361 Views
Last Modified: 2014-04-12
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.
0
Comment
Question by:Moti Mashiah
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 39995613
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
 
LVL 1

Author Comment

by:Moti Mashiah
ID: 39996104
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
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39996118
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
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 39996184
excellent thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question