|
-
Jun 10th, 2002, 11:08 AM
#1
Thread Starter
Hyperactive Member
locking text box
How do you lock a text box in .net? Setting the Locked property default to true doesn't seem to do it. How can I get at it programmatically?
A cynic knows the price of everything but the value of nothing.
-
Jun 10th, 2002, 11:20 AM
#2
according to the class viewer..textbox doesnt have a locked property
try IsAccessible or Enabled
both of these are boolean properties.
-
Jun 10th, 2002, 11:21 AM
#3
there is also a ReadOnly property..
-
Mar 8th, 2004, 10:19 PM
#4
Frenzied Member
The enabled property is pretty much the same as the locked property except that the when Enabled=False, the text box can't take the focus and the text is very pale.
Is there any way to change the text when Enabled=True to make it stand out more?
-
Mar 8th, 2004, 10:30 PM
#5
Addicted Member
i don't think i know what i'm talking about, so i might confuse you, so you can just disregard the following: i think you'll have to make a new custom control, inherit textbox, then write a code for when me.enabled = true, then the text color changes. but i guess it's contradicting...
-
Mar 8th, 2004, 11:03 PM
#6
Addicted Member
If you set the textbox to readonly=true, then use this code to make it appear as a normal textbox:
Code:
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then
Dim txt As TextBox = DirectCast(ctl, TextBox)
If txt.ReadOnly = True Then
txt.BackColor = Color.FromKnownColor(KnownColor.ActiveCaptionText)
End If
End If
Next
-
Mar 8th, 2004, 11:48 PM
#7
Frenzied Member
Thanks for that. Just what I needed. It's ironic that a text box's read-only property is a writable property.
I tried the same analogy to apply it to a combo box but it didn't work.
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
|