Prevent user from changing text box on Windows Form

I have a windows form project that depending on the user i need to make certain text boxes read only.  I have tried using the following but it does not seem to have an effect and does not make it read only.

Me.Textbox1.Readonly = True

I am not sure if this is the correct approach.

Any help would be appreciated
Mike_StevensAsked:
Who is Participating?
 
corvetteguruConnect With a Mentor Commented:
Then my answer is the one you need... I am also using 2010!
0
 
corvetteguruCommented:
Which version? In certain versions you can me.txtbox.locked = true, but you can't do that in 2010... or 2008, IIRC.

You can always use me.txtbox.enabled = false, the downside is you can't see it as well.

But Readonly is the acceptable property, when I double checked it, the help text says "Controls whether the text in the edit control can be changed or not." Sounds pretty definitive.

Finally, you just don't update those fields when you hit save.
0
 
Mike_StevensAuthor Commented:
Visual Studio 2010
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Are you sure it's not working?

Readonly() prevents changes to the TextBox, but the user can still interact with the control.  The cursor changes and the user can select text and even copy it...
0
 
Mike_StevensAuthor Commented:
I can selected text and change it even after i set the readonly property to true
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Can you post more code then?...or possibly upload a sample project?
0
 
Ess KayEntrapenuerCommented:
readonly, is the correct approach.
you can also install infragistics and use ultratextbox which has differnt ways of disabling it.


If you really want to be classy, put a transparent label over the textbox. and use senttoback / sendtofront
instead of readonly
0
 
corvetteguruCommented:
I have used infragistics... unless it  has improved, it is an overweight pig with some serious issues. I used it with .NET 2005... pretty, yes, reasonably functional, but the actual implementation leaves a lot to be desired. Oh, and it's REALLY expensive.
0
 
Ess KayEntrapenuerCommented:
Its been heavily improved,  now its a colossal pig,  but they update it at least twice a year,  so the bugs are gone
0
 
corvetteguruCommented:
Thank God the bugs are out... it made the product seriously unwieldy. Have they improved the performance of the various grids?
0
 
corvetteguruCommented:
Any status update on this issue?
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.