-
Apr 17th, 2010, 02:29 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Code to lock a Textbox!
What is the code to lock a Textbox?
The following code throws an error:
Code:
txtVNO.LOCKED = True
The error is : 'Locked' is not a member of 'System.Windows.Forms.Text'
Then how to lock a textbox? Please advise.
Regards.
-
Apr 17th, 2010, 02:37 AM
#2
Re: Code to lock a Textbox!
Try:
Code:
txtVNO.enabled = False;
Edit:
If you are using the text box for output purposes try using a label instead.
Last edited by Nightwalker83; Apr 17th, 2010 at 02:41 AM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Apr 17th, 2010, 02:40 AM
#3
Thread Starter
Fanatic Member
Re: Code to lock a Textbox!
Originally Posted by Nightwalker83
Try:
Code:
txtVNO.enabled = False;
It works but it disables the textbox. No other way?
-
Apr 17th, 2010, 02:44 AM
#4
Re: Code to lock a Textbox!
Originally Posted by VBLearner6
It works but it disables the textbox. No other way?
Don't think so! You could try using a label.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Apr 17th, 2010, 07:07 AM
#5
Re: Code to lock a Textbox!
How about
Code:
txtVNO.ReadOnly = True
txtVNO.Backcolor= Color.White
-
Apr 17th, 2010, 08:33 AM
#6
Re: Code to lock a Textbox!
Locked is a property of controls for the designer, it has nothing to do with the controls at runtime (Locked simply means you can't move or resize a control in the designer with the mouse)
You either disable the TextBox (.Enabled = False) or, since it's a TextBox you use the ReadOnly property of which Hack has already shown an example. Though I wouldn't use static color as that it might not match the user's theme (color scheme) I would set the .BackColor = SystemColors.Window instead:
Code:
txtVNO.ReadOnly = True
txtVNO.Backcolor= SystemColors.Window
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|