Solved

Prevent user from changing text box on Windows Form

Posted on 2012-12-26
11
258 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 500 total points
ID: 38721795
Then my answer is the one you need... I am also using 2010!
0
Major Incident Management Communications

Major incidents and IT service outages cost companies millions. Often the solution to minimizing damage is automated communication. Find out more in our Major Incident Management Communications infographic.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

734 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