Solved

C# textbox

Posted on 2014-04-11
4
351 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
  • 2
  • 2
4 Comments
 
LVL 62

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 62

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short film showing how OnPage and Connectwise integration works.
Send secure, cloud-based, encrypted alerts and maintain HIPAA compliant messaging. Integrates priority & secure messaging into one application. Ensures IT, emergency respondents and healthcare professionals that their critical messages are never mis…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now