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
Printable View
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
To prevent a textbox from receiving input then use:VB Code:
TextBox1.ReadOnly = True
Yes, and if you want to to avoid it becomes gray, choose explicitly the background color (for example: White).
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.Quote:
Originally posted by TouchOdeath
or TextBox1.enabled = False
TG
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
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.
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.Quote:
Originally Posted by Plucky
Didn't get yet..:( Can't understand,
write code please.. :)
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.
ERROR :(
For without Next
help.........
Make sure you copied my source code correctly.Quote:
Originally Posted by Plucky
You may want to look into getting a VB.Net book.
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 falseQuote:
Originally Posted by Plucky
Just make sure you leave the unlock button enabled
Would you like to have your shoe laces tied too?
Sir Kasracer,
Its working now.. thank you very much,
you are really helpful,