Adding check boxes to Tree List

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Adding check boxes to Tree List

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by synergos >> Wed, 6 Nov 2002 3:02:04 GMT

Can anyone provide a clue as how to create a tree list with a check box attached to each item within the list?

Thanks
Synergos

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Adding check boxes to Tree List

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by hml >> Wed, 6 Nov 2002 9:13:40 GMT

Yes

It is a bit of work but this is what we did:

We made two pictures, checked and unchecked which we stored on the form in an invisible picture control.
The itemData attribute of the list box was used to store whether the item was checked or not. (0=not selected, otherwise selected)
When each item was clicked (Used the picture click method with whatClicked = ListBox.PictureClick_ItemPicture,) the itemData property for the item clicked was updated and then the itemPicture for that item was updated to the check box or just a empty square (unchecked)

We also added a partially check box (gray tick) to signal when some of the children in the tree were selected and some code to the pictureClick method to check the siblings and update the ancestors. Also needed some code to update the children when the parent was selected or unselected.

Adding methods to get the parent item and to populate a collection with the immediate children made the code a little easier to understand.

The next step would be to wrap this up into a subclassed control, which also allows you to code the expand and contract in the control class as well saving on form event code.

Torrie

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Adding check boxes to Tree List

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:40 pm

by allistar >> Wed, 6 Nov 2002 20:57:46 GMT

On Wed, 6 Nov 2002 3:02:04 GMT, synergos@bigpond.com (synergos) wrote:

Can anyone provide a clue as how to create a tree list with a check box attached to each item within the list?

Thanks
Synergos

We create a subclassed ListBox control (called "CheckBoxList"). On
that we added a "myTable" reference of type "Table". on the
windowCreated event of the CheckBoxList control we create the table
and add embed it in the list box (by setting the .parent property to self. Then add it to the form using the form.addControl method.

When the table is created you can them give it one column with the inputType of each cell set to InputType_CheckBox.

We have modified the events so that when an item in the list box is expanded (for multi level list boxes) that the appropriate rows in the table are make visible/invisible. Write methods on the list box to retrieve and set the checked state of each item in the list.

The nice thing about this implimentation is that you can easily have multiple colunms of checks in the table.

Regards,
Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 18 guests