Discussion:
Checkable Listboxes
Alex Hochberger
2007-07-05 20:52:35 UTC
Permalink
Hi everyone, wondering if anyone tackled this issue and has a class
they can send me before I reinvent the wheel.

So I use a bunch of mapping tables for m:n relationships, and I wanted
an easy way to allow people to set them. For this example, I'm trying
to map an article to a category... i.e. articles can be in 0, 1, or
more categories.

My solution is a listbox, column 0 (width 0) as the primary key of the
category, and column 1 has the name of the category. I use a simple
Cache bound to the listbox, and that gets me my values, and I format
the listbox to have the checkboxes in the Window's open event.

However, when I select an article, I want to get a list of mapped
categories, and check the appropriate boxes. I could simply have the
Cache on completion loop through and check them, but it seemed more
elegant to subclass the listbox, and create a second binding option as
set checked, so I bind it with Cache1 to get the values, and Cache2
returns a set of Ids to check, and upon data from Cache2, loops
through and checks or unchecks the boxes.

On the change, we just send an update to the server.

Has anyone done this, otherwse, any suggestions for how to create a
second bindable "populateData" option?

Thanks,
Alex

Loading...