Solved

Prevent user from changing text box on Windows Form

Posted on 2012-12-26
11
257 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…

828 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