dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Apr 29, 2002

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Force Tri-State Checkbox Cycling


The CheckBox control in VB supports three positions: Checked, Unchecked, and Grayed. Unfortunately, the default behavior for the control is to cycle between Checked and Unchecked. To set it to Grayed, you must do it programatically. This code shows you how to cycle between the three positions (the order is Checked->Unchecked->Grayed->Checked ...):
 
Private Sub Check1_Click()
Static iState As CheckBoxConstants
Static bUserClick As Boolean
' Trap if the user clicked on the control
' or if the event was fired because you
' changed the value below
bUserClick = (iState <> Check1.Value)
' Prevents you from entering an infinite
' loop and getting an Out of Stack Space error
If bUserClick Then
Select Case iState
Case vbChecked
iState = vbUnchecked
Case vbUnchecked
iState = vbGrayed
Case vbGrayed
iState = vbChecked
End Select
' This will raise another click event but
' your boolean check prevents you from looping
Check1.Value = iState
End If
End Sub
Eric Litwin
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date