Solved

Prevent user from changing text box on Windows Form

Posted on 2012-12-26
11
252 Views
Last Modified: 2013-02-14
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
0
Comment
Question by:Mike_Stevens
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 2

Expert Comment

by:corvetteguru
ID: 38721751
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
 

Author Comment

by:Mike_Stevens
ID: 38721763
Visual Studio 2010
0
 
LVL 2

Accepted Solution

by:
corvetteguru earned 500 total points
ID: 38721795
Then my answer is the one you need... I am also using 2010!
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 38721846
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
 

Author Comment

by:Mike_Stevens
ID: 38721849
I can selected text and change it even after i set the readonly property to true
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 38721866
Can you post more code then?...or possibly upload a sample project?
0
 
LVL 15

Expert Comment

by:Ess Kay
ID: 38721901
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
 
LVL 2

Expert Comment

by:corvetteguru
ID: 38722348
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
 
LVL 15

Expert Comment

by:Ess Kay
ID: 38722352
Its been heavily improved,  now its a colossal pig,  but they update it at least twice a year,  so the bugs are gone
0
 
LVL 2

Expert Comment

by:corvetteguru
ID: 38722472
Thank God the bugs are out... it made the product seriously unwieldy. Have they improved the performance of the various grids?
0
 
LVL 2

Expert Comment

by:corvetteguru
ID: 38745825
Any status update on this issue?
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

746 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

15 Experts available now in Live!

Get 1:1 Help Now