6 Replies Latest reply on Feb 12, 2008 9:00 AM by jxmot

    need to create a "checkedlistbox"

    jxmot Level 1

      I need to create a custom component that has the following -

      - is a listbox that appears as a MS-VB checkedlistbox
      - ability to be loaded at runtime from a datasource (XML data file)

      I've searched forums and other websites looking for anything similar or any related information but haven't found anything.

      thanks in advance!
        • 1. Re: need to create a "checkedlistbox"
          Flex harUI Adobe Employee
          Try a List with itemRenderer="CheckBox"
          • 2. Re: need to create a "checkedlistbox"
            jxmot Level 1
            Thanks! That helped alot. I was able to get the checkboxes to show in the lists. But now I'm having a problem trying to determine how to make the checkboxes "dynamic" and read their labels from an XML file. I know I need a data source, I had that working for a grid.

            Here's an example of the data file I need to read into 4 lists -

            <?xml version="1.0" encoding="utf-8" ?>





            • 3. Re: need to create a "checkedlistbox"
              ntsiii Level 3
              Alex, you know it is more complicated than that! (I am guessing at your identity, but confident)

              jxmot, there are several things that have to happen with an item renderer.
              1) They must be entirely data-driven(or static). That is, the checked state of the control must get its value from the list's dataProvider item, You can certainly get the label as well.
              2) If interactive (user can click), then that action must update the same dataProvider item property that was used to set the checked state.
              3) To access the checked states, you must loop over the dataProvider and examine that property. (there are other ways, like using a dictionary, but that is beyond the scope of this post)

              There are many ways to implement an item renderer.

              Google: Flex CheckBox itemRenderer

              You will find a wealth of examples.

              • 4. Re: need to create a "checkedlistbox"
                jxmot Level 1

                Thanks for the help. But #2 and #1 have me a bit concerned that I may not be able to create what I need. I would like to create a checkbox list that obtains its labels from one source while being able to load and save the checked states to an XML file. Is that possible?

                • 5. Re: need to create a "checkedlistbox"
                  ntsiii Level 3
                  No, that is ok. Tghe data-driven list is on thing, what you do with the updated data is someting else. The point is, you will need a collection that is the model for your list. The label, and the state of the checkbox must be in properties in each item in that list, and the dataProvider must update the "selected" property when a user clicks the checkbox.

                  Then, when you are ready, you can save that data however you want, either as it is, or preprocessing it as needed.

                  • 6. Re: need to create a "checkedlistbox"
                    jxmot Level 1
                    This is starting to make more sense now... thanks! However I'm not sure yet how to read my XML data (see my 3rd post w/ the xml data in it) into an array or collection. That would take care of my checkbox labels.

                    Then after I've got the labels the data I want to read and use to check the boxes is -

                    <!-- Only one box to check -->
                    <!-- Multiple boxes to check, and -->
                    <!-- NOT contiguous -->
                    <!-- Same here -->
                    <!-- No checkboxes are to be clicked -->

                    Where "list_X-item_Y" is the label of a checkbox that was checked.