?
Solved

Prevent user from changing text box on Windows Form

Posted on 2012-12-26
11
Medium Priority
?
262 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
[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
  • 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 2000 total points
ID: 38721795
Then my answer is the one you need... I am also using 2010!
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 86

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
 
LVL 86

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

752 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