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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make datetimepicker invisible if chkbox unchecked

Status
Not open for further replies.

honeypot

Technical User
Mar 6, 2001
147
GB
Hi all :)
on my windows form, amongst other things, i have a checkbox for 'reply required', so if a reply is required then the user chooses a date from the datetimepicker. if the checkbox is unchecked, the the datetimepicker becomes invisible. i got this working by using the following code:

If chkRep.Checked = False Then
Me.dtpRep.Visible = False

only thing is, its invisible all the time now! wot do i add to the code to make it work properly?
Thanx!
 
Try this in your checkbox click event
Code:
dtpRep.Visible = chkRep.Checked
If the checkbox is checked, the datetime picker is visible. If it's not checked, the datetime picker is not visible.

You can reverse the behavior by putting a "Not" in.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
ive tried a few variations but none seem to work:

If chkRep.Checked = False Then
Me.dtpRep.Visible = False
ElseIf chkRep.Checked = True Then
Me.dtpRep.Visible = True
End If

and:

If chkRep.Checked = False Then
Me.dtpRep.Visible = False
Else : Me.dtpRep.Visible = True

the datetimepicker remains invisible on both occasions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top