Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locking a Checkbox

Status
Not open for further replies.

VB400

Programmer
Sep 8, 1999
359
US

I want to lock a checkbox but there is no property that allows me to do so. The Enabled property works but it dimms the attached text and it makes it hard to see.

Additionally, when I display a form in View only mode, I change the background color of all my controls to gray, following the lead of MS. However, with a checkbox, only the text portion of the control is effected by the .BackColor property -- the actual checkbox is not.

Any ideas on solving either/both problems?
 
Nice problem!!! It seems to be no way to do this by Checkbox. You can try this trick:

Private Sub Check1_Click()
If Check1.Value = 1 Then Check1.Value = 0
End Sub

Or you can test a condition before you do this.

Another possible way is to build a new ActiveX control derived from CheckBox that has a new Property named 'Locked'. If you are interested I can send you the Control for free!

mohmehran@yahoo.com
 
> Any ideas on solving either/both problems? <

I would do as Mohmehran suggested -- create a new ActiveX control derived from the checkbox that implements the behavior you want. We've done this several times, mostly for text boxes.

Chip H.
 

I appreciate the free offer; however, I think it's time for me to create my first control -- I've been putting it off for quite a while. I will let you know if need help on that issue.

Since both of you create your own controls, let me ask you this: Are there any downsides to creating our own controls (distribution, registration, etc.) ?
 
No, unless you add licensing to your control. So don't check the 'Require Licensing' in project settings. When you package your application using Package and Deployment wizard or InstallShield, the necessary .ocx file will be put into your setup program and will be installed into your client's machine.

And also, when you build an ActiveX control, you shouldn't change its public interface (property and method names and arguments) or previous your application won't function corectly. Good Luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top