|
-
Feb 2nd, 2016, 12:58 PM
#1
Thread Starter
Hyperactive Member
How to make unchangeable checkbox?
I need to use checkbox(or similar symbol) to notify some steps had been completed. But when use checkbox, the ueser can click to modify it or change it. So I want to fulfill unchangeable checkboxes or similar symbol, so how to do it?
-
Feb 2nd, 2016, 01:17 PM
#2
Re: How to make unchangeable checkbox?
Where is this checkbox located (worksheet, UserForm)?
If it is on a worksheet is it Forms control or an ActiveX control?
-
Feb 2nd, 2016, 02:42 PM
#3
Thread Starter
Hyperactive Member
Re: How to make unchangeable checkbox?
 Originally Posted by TnTinMN
Where is this checkbox located (worksheet, UserForm)?
If it is on a worksheet is it Forms control or an ActiveX control?
They are all in UserForm
-
Feb 2nd, 2016, 03:26 PM
#4
Re: How to make unchangeable checkbox?
The simplest way is to set the CheckBox control's Enabled property to false. However that makes the control aesthetically unappealing.
The only option I know of is to constrain the value from changing when it is clicked. Use the control's Tag property to store the desired value and handle the Click event.
Code:
Private Sub UserForm_Initialize()
SetCheckBox CheckBox1, False
End Sub
Private Sub CheckBox1_Click()
RestrainCheckBoxValue CheckBox1
End Sub
Private Sub RestrainCheckBoxValue(cb As MSForms.CheckBox)
If cb.value <> cb.Tag Then cb.value = cb.Tag
End Sub
Private Sub SetCheckBox(cb As MSForms.CheckBox, value As Boolean)
' use this method to programatically change the CaheckBox Value
' changing the MSForms.CheckBox.Value property from True to False or False to True
' invokes the MSForms.CheckBox.Click event, so set then Tag property 1st
cb.Tag = value
cb.value = value
End Sub
-
Feb 2nd, 2016, 03:31 PM
#5
Thread Starter
Hyperactive Member
Re: How to make unchangeable checkbox?
Thank you. Actually we hope to use a small symbol or picture to notify the user that this step had been completed. This symbol or picture like a checkbox but can not been modify. So I just do not know how to find a symbol or picture looks like a checkbox...
-
Feb 2nd, 2016, 05:07 PM
#6
Re: How to make unchangeable checkbox?
I would think that searching for an image wouldn't be that hard, but I haven't tried it yet.
Worse case (I guess), would be just put a checkbox on a form, start the program and check the checkbox.
Then hit Alt-Print Screen to screen capture the window.
Open up Paint, and Ctr-V to paste the captured window into paint.
Choose the Select option from the toolbar, drag a selection box around the checkbox, and select the Crop option.
You should now have a small image of a checked checkbox, which you can save (I usually let it default to .png file).
p.s. I just did a search on "checkbox image", and saw a number of images that could be used. One example page.
Last edited by passel; Feb 2nd, 2016 at 05:12 PM.
-
Feb 2nd, 2016, 07:52 PM
#7
Re: How to make unchangeable checkbox?
I would think that an image control would work... then you just load a checkmark image into it... that's how we do it.
-tg
-
Feb 2nd, 2016, 11:55 PM
#8
Thread Starter
Hyperactive Member
Re: How to make unchangeable checkbox?
 Originally Posted by techgnome
I would think that an image control would work... then you just load a checkmark image into it... that's how we do it.
-tg
Thank you, I will try it.
-
Feb 3rd, 2016, 02:29 AM
#9
Re: How to make unchangeable checkbox?
checkbox controls have a locked property, this will prevent the user from clicking, the value can still be changed by code
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|