TreeView with Three-State Checkboxes

Over the last few months, I have been involved with a cople of projects that required the use of checkboxes in a TreeView control.  One of the frustrations with the standard TreeView is that you can't show a partial selection to indicate that some of the children are selected.  A partial selection in a complex tree allows the user to easily determine where the selections are, even if the tree is not completely expanded.  A similar idea is used in manu backup programs to allow the user to select the files to be backed up.

With the current project requiring such a TreeView written in VB, I have come up with a simple solution for this problem.  The attached code displays a bitmap next to the node label.  Depending on the selections in the parent and children nodes, the bitmap displayed will show a checked, unchecked or partially checked box.  There are also two functions to process a state change and update the nedes above and below the node which changed state.

To add this sample to your project do the following:

  1. Copy mod3StateTreeViewFunctions.bas and checkboxes.res to your project directory and add them to your project.
  2. Add an ImageList object to the form where your TreeView resides
  3. Initialize ImageList with tri-state checkboxes by calling InitImageList <NameOfImageList>  (see Form_Load sub of the demo form)
  4. Bind the ImageList to your treeview
  5. Populate TreeView with values
  6. nbsp; <optional> Set checkboxes in the TreeView, updating the parents and children

To capture a state change event (see demo form for the sample code):

  1. Use the MouseDown event to capture the x and y location of the click.
  2. Use the Click event to check if the click is near the checkbox bitmap.  This is tricky as the offset of nodeTest in the demo may need to be adjusted depending on the ScaleMode you use.  I used Twips, the default selection.
  3. <optional> You may want to filter on a specific mouse button (not implemented in demo)
  4. <optional> Use the KeyPress event to capture keyboard ordered state change, I used space to trigger this
  5. If a state change is to occur, call ProcessStateChange passing the node that is about to be changed

Downloads

Download demo project - 6 Kb


Comments

  • subordinate to unseat in soccer jerseys constitutional classify on pass on coming this biggest soccer party.

    Posted by Merejensejage on 06/20/2013 12:57pm

    "He scores goals and it's as simple as that, and often in major competitions or at crucial moments, like the recent Manchester United game. Dirk is happy with the extension, and I am sure we will enjoy having him." Liverpool forward Dirk Kuyt has agreed a one-year contract extension to remain at Anfield until 2013, his management company have announced. Although signed as a striker in a 锟斤拷9million deal, Kuyt has been deployed most successfully in a right-sided midfield role. He scored his first hat-trick for the [url=http://www.worldcupsoccerfacts.info/]Cheap soccer jerseys[/url] club in last month's impressive Premier League win over Manchester United and has since followed up with further goals against Sunderland and Manchester City. Manager Kenny Dalglish was quoted in the release as saying: "He never gives up, fights with everything and he is simply a good footballer. Yet it is not principally for goals that Kuyt has earned a regular starting place in his five seasons at Anfield, [url=http://www.worldcupsoccerfacts.info/]2014 world cup soccer jerseys[/url] but his all-round contribution and tireless work-rate. In a news release issued by Sport-Promotion, the 30-year-old said: "I am very happy. We have spent a long time [in discussions] but always with the intention to reach an agreement. The Netherlands international, who joined the Reds from Feyenoord in 2006, was contracted until next summer but has been rewarded for his form this season. "All the conversations were conducted [url=http://www.worldcupsoccerfacts.info/]wholesale soccer jerseys[/url] in a friendly atmosphere. It fits perfectly with the feeling I got at this club. Since the day I first walked in, I felt welcome. That feeling has never left." The release added that Kuyt had been discussing new terms with the club for the past month. Kuyt, who played in the FIFA World Cup™ final with the Netherlands last summer, has scored 11 times for the Reds in all competitions this season. Since the day I first walked in, I felt welcome. That feeling has [url=http://www.worldcupsoccerfacts.info/]wholesale soccer jerseys[/url] never left.Dirk Kuyt, Liverpool forward

    Reply
  • wholesale soccer jerseys autochthon loam pass on coming this biggest soccer party.

    Posted by Merejensejage on 06/16/2013 02:06am

    Kicking off our look at new assistant coaches in the AFC South who will be especially important in 2012, we head to Houston. Gary Kubiak's got continuity with his staff, [url=http://worldcupsoccerfacts.info/]Cheap soccer jerseys[/url] so we've only got two guys to choose from. Quarterbacks coach Karl Dorrell is the easy selection. He replaced Gregg Knapp, who went to Oakland to be the offensive coordinator. Quarterbacks Matt Schaub and T.J. Yates loved working with Knapp. Now they are getting to know Dorrell, who came to Houston from Miami, where he didn't have much quarterback talent. He's got a Denver connection, too, and the three seasons he was with [url=http://worldcupsoccerfacts.info/]wholesale soccer jerseys[/url] the Broncos when he overlapped with Kubiak there produced the tie that landed him this gig. While Kubiak and offensive coordinator Rick Dennison will be heavily involved in the offense, a new position coach is certain to have a bearing on Schaub's performance. And Schaub's performance may be as important of a story as there is in the AFC South this season. Schaub is coming off a serious foot injury that sidelined him last season and heading into a contract year. He hears constantly about being fragile -- a label that's not really fair -- and hasn't been in position to [url=http://worldcupsoccerfacts.info/]http://worldcupsoccerfacts.info/[/url] produce in the big moment of big games very often.

    Reply
  • womens babydoll

    Posted by Fishnetrv1051 on 03/29/2013 08:02am

    http://sexycostumesboutique.webs.com - Sweetheart Nurse Bedroom CostumeSexy lingerie is an easy way to add a sizzle into your relationship Babydolls are even available that more closely resemble the older bed jackets, featuring one or two front closures http://SexyChemise.webs.com - womens chemiseIn terms of choosing the right bra, you can look for the proper size as well as the one that gives most comfort Click on selected style and see available options http://sexycostumesboutique.webs.com - Nurse CostumesLingerie is often a thing perfect for all slim women to highlight their sexiness and sexual appeal This is an online dreamgirl lingerie retailer which offers free shipping for orders that are above $75 http://cheapspicylingerie.webs.com - plus size corsets cheapEven if lingerie attracts you but is not of your size, you should avoid buying it Gradually creeping shorter, and featuring ever more daring fabrics, baby doll lingerie made the switch from simple nightwear to true sexy lingerie http://sexylingeriecostumese.webs.com - French Maid LingerieRed and black are the most popular colors for lingerie It seems that men even back then liked to see their women's breasts pushed up and squeezed together! A bustier is basically an underwire bra that extends down to the waistline

    Reply
  • fake oakley sunglasses

    Posted by ngliliImpumpljj on 03/28/2013 08:37pm

    http://discountsunglasseshoo.webs.com - discount ray ban sunglasses cheap sunglasses http://fakeguccisunglasses.webs.com - fake oakley sunglasses oakley discount http://qualityguccisunglass.webs.com - cheap sunglasses cheap wayfarer sunglasses http://qualityguccisunglass.webs.com - oakley sunglasses cheap fake ray ban http://discountsunglassesfinewebs.com - discount sunglasses discount ray ban

    Reply
  • cheap ugg boots iCir rBzi

    Posted by Mandyrwl on 03/09/2013 11:44am

    botas ugg baratas sfrxwved botas ugg espa?a teurccdw botas ugg ibjzfdtp comprar ugg online kodwznbw ugg australia rkqsxeva ugg baratas mniqjxgr ugg espa?a rmjjfytl ugg online pexigttb ugg azvgrklq

    Reply
  • ugg boots infwmj http://www.cheapfashionshoesas.com/

    Posted by Suttonkwi on 01/27/2013 07:40am

    2vAte nike outlet fTtg Michael Kors outlet yPob ugg boots 2zVzt monster beats 8aDql Cheap nfl jerseys 6mLgi uggs sko 0mCgo burberry outlet 4hLcc longchamp 2kYfs cheap nike free run 8gThc cheap ugg boots 1fQvd monster beats 4wGfc ugg 0lFkp GHD Hair Straightener 3mYqz 9pYcr

    Reply
  • christian louboutin shoes vancouver bc

    Posted by boowiffRodial on 11/16/2012 02:52pm

    TreeView with Three-State Checkboxes vgqdzr aimorkv lpwqil louis vuitton handbags gm louis vuitton purses louis vuitton outlet ct cplcjno obgbxbes beats by dre kobe bryant edition cheap beats dre cheap beats by dre aus ykgwzdr pndup coach outlet hagerstown md coach factory outlet online coach handbags knockoffs bktmshzs christian louboutin shoes saks christian louboutin cheap christian louboutin outlet hk tuydmtzs

    Reply
  • louis vuitton outlet wrentham ma

    Posted by Occadanectate on 11/13/2012 01:29am

    TreeView with Three-State Checkboxes txxtbx vgcbccz jstrnp coach outlet great mall coach factory last year's coach handbags mwixfvs nopuowqo christian louboutin shoes uk sale cheap christian louboutin face christian louboutin outlet uonezrf gclbn ugg outlet buffalo ugg boots ugg boots for kids miogzkht louis vuitton handbags products louis vuitton outlet online louis vuitton outlet are they fake ijyyvtrm

    Reply
  • louis vuitton outlet ebay

    Posted by Bamnsorma on 11/12/2012 10:31pm

    qlvrd jodsu quality replica louis vuitton handbags louis vuitton belt louis vuitton outlet bay area azheo hcevcn TreeView with Three-State Checkboxes pexilvu beats by dre verify cheap beats dr dre cheap beats by dre us wccpzyn wzdyz coach outlet reno nv coach factory outlet online coach handbags for sale ssvliscz christian louboutin shoes jennifer lopez chrsitian louboutin shoes outlet christian louboutin outlet bags bqdshpfx

    Reply
  • christian louboutin outlet

    Posted by stoinqqb on 11/12/2012 02:14am

    ERS PRINTED IN THE U jsk n ekingwolfcspl1 boj t tnv a nst New New England agy b bhk f loj d uwu m cgk d dud h nrv v zdr f grc d tiw z gu87

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Information is data with context. The era of Big Data has begun demonstrating to information security that there is more that can, and must, be done to identify threats, reduce risk, address fraud, and improve compliance monitoring activities by bringing better context to data and thereby creating information for actionable intelligence. This analyst report sets the stage and provides insights into IT and information security practitioners' perceptions of the impediments to, and the solutions necessary for, …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds