views:

1146

answers:

3

Hey,

I've got a TextBox on a form that I am using to just display data. I have set it to ReadOnly which stops the user from changing the data displayed in the TextBox. Although the user can still highlight the data in the TextBox, how do I disable this?

NOTE: I know using a label would be much easier, although for some reason the label wont let me display the data how I would like. I want to display a number starting from the right of the display area, IE: " 25", although the label displays it like "25 ". I have tried making the label right-justified this does not solve the issue. Therefore I am using a TextBox.

+1  A: 
TextBox1.Enabled = false;

Or you can use the label with the property RightToLeft set to True

Marwan Aouida
I don't want to set the Enabled property to false because the text will be gray. I just tried the RightToLeft property, and it made no difference.
You can change the textcolor after you disabled the textbox.
Ikke
+1  A: 

You can display right aligned text in label by setting TextAlign property to e.g. MiddleRight. Remember also to set AutoSize property to false, otherwise it will resize the label and the position will change to left.

bbmud
Thanks to both of you! Setting AutoSize to false as well as the RightToLeft to true solved my issue!
A: 

i am reza. i am a new proprty for textbext for langosh rhit and left.

reza
Sorry, but it's not clear what you are trying to say. At all.
sth