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: VB
Expertise: Intermediate
Nov 18, 2004

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


A Better Way to Validate a Node Checkbox in a Treeview

You cannot change the value of a nodes checkbox in the event treeview_NodeCheck as explained in this tip. Besides that, the event doesn't fire at all when clicking a nodes checkbox and dragging the mouse out of the treeview before releasing your mousebutton.

The following code is a decent work-around:


Private Sub treeview_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
    Dim objNode As MSComctlLib.Node
    Set objNode = treeview.HitTest(x, y)
    If Not objNode Is Nothing Then Set treeview.SelectedItem = objNode
End Sub

Private Sub treeview_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
    'Do whatever validation you want on treeview.SelectedItem
    'You might want to check here for a not set SelectedItem
End Sub
Eric van Blokland
 
Comment and Contribute

 

 

 

 

 


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

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date