|
-
Jun 21st, 2004, 09:34 AM
#1
Thread Starter
Member
Textbox Lock
I haven't been using Vb.net in a while and was wondering just how to lock a textbox for input.
ie in vb6
Code:
textbox1.locked = true
U S A
Visual Studio .NET
Windows XP
-
Jun 21st, 2004, 09:51 AM
#2
Addicted Member
To prevent a textbox from receiving input then use:
-
Jun 21st, 2004, 10:48 AM
#3
Hyperactive Member
Yes, and if you want to to avoid it becomes gray, choose explicitly the background color (for example: White).
Live long and prosper (Mr. Spock)
-
Jun 21st, 2004, 11:33 AM
#4
Junior Member
or TextBox1.enabled = False
-
Jun 21st, 2004, 11:39 AM
#5
Originally posted by TouchOdeath
or TextBox1.enabled = False
Problem with that is if you need to scroll or copy data out of the textbox. By setting ReadOnly = True, you can still scroll and copy, just not paste or edit the text.
TG
-
Dec 24th, 2005, 05:11 AM
#6
Lively Member
Re: Textbox Lock
hi there,
I'm wonder how to make it possible:
Click on command1, Controls gone Lock,
Click on command2, Control came alive (unlock),
----- dont say it like that : textbox.txt.lock = ture
I want to make all controls on form 'Lock' on single click..
plz help
-
Dec 24th, 2005, 05:19 AM
#7
Re: Textbox Lock
Depends on the controls you're using. You could make a foreach loop to look for Command buttons and set their Enabled property to False. For TextBoxes, set them to ReadOnly.
-
Dec 24th, 2005, 05:24 AM
#8
Re: Textbox Lock
 Originally Posted by Plucky
hi there,
I'm wonder how to make it possible:
Click on command1, Controls gone Lock,
Click on command2, Control came alive (unlock),
----- dont say it like that : textbox.txt.lock = ture
I want to make all controls on form 'Lock' on single click..
plz help
Control.Lock does not have any effect at run time. It is a design time only property and setting it to True prevents you moving the control in the designer. All controls have an Enabled property and you can set its value in code whenever you like. To enable and disable multiple controls it is easiest to put them all in the same container, like a Panel, and just set the Enabled property of the container. Note that is still possible to have another control, like the button you want to use to toggle the Enabled state, show over the container without actually being in the container by manipulating the z-order.
-
Dec 24th, 2005, 05:43 AM
#9
Lively Member
Re: Textbox Lock
Didn't get yet.. Can't understand,
write code please..
-
Dec 24th, 2005, 05:50 AM
#10
Re: Textbox Lock
VB Code:
Dim t As Control
For Each t In Me.Controls
If TypeOf t Is TextBox Then
t.Enabled = False
End If
If TypeOf t Is Button Then
t.Enabled = False
End If
Next
Something like that should get you started.
-
Dec 24th, 2005, 06:19 AM
#11
Lively Member
Re: Textbox Lock
ERROR 
For without Next
help.........
-
Dec 24th, 2005, 06:34 AM
#12
Re: Textbox Lock
 Originally Posted by Plucky
ERROR 
For without Next
help.........
Make sure you copied my source code correctly.
You may want to look into getting a VB.Net book.
-
Dec 24th, 2005, 06:48 AM
#13
Lively Member
Re: Textbox Lock
Dear, Kasracer
you are right i did mistake, but please tell me how to make Unlock all the fields,
when i click on Add Record Command Button.
plz
-
Dec 24th, 2005, 06:51 AM
#14
Re: Textbox Lock
 Originally Posted by Plucky
Dear, Kasracer
you are right i did mistake, but please tell me how to make Unlock all the fields,
when i click on Add Record Command Button.
plz
Use true instead of false
Just make sure you leave the unlock button enabled
-
Dec 24th, 2005, 07:04 AM
#15
Re: Textbox Lock
Would you like to have your shoe laces tied too?
-
Dec 24th, 2005, 07:18 AM
#16
Lively Member
Re: Textbox Lock
Sir Kasracer,
Its working now.. thank you very much,
you are really helpful,
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
|