Skip to main content
Participant
November 29, 2013
Answered

Create a Listbox in Dialog

  • November 29, 2013
  • 1 reply
  • 935 views

I want to create a simple Listbox in a dialog and populate it with some dynamic strings. I placed a Treeview in dialog using this code in fr-file:

TreeViewWidget

        (

            myListID,            // fWidgetId

            kSysStaticTextPMRsrcId,        // fRsrcId, fRsrcPlugin

            kBindNone,

            Frame( 10, 10, 280, 200  ),

            kTrue,            // fVisible

            kTrue,            // fEnabled

            kTrue,            // fEraseBeforeDraw

            kInterfacePaletteFill,            // InterfaceColor to erase to

            "",        // control label

            kFalse,        // Display Root Node

            kFalse,        // Use H scroll bar

            kTrue,        // Use V scroll bar

            20,        // Vertical Scroll Button increment

            20,        // Vertical Thumb Scroll increment

            0,        // Horizontal Scroll Button increment

            0,        // Horizontal Thumb Scroll increment

            1,        // Items selectable, 0 = No Selection, 1 = Single Selection, 2 = Multiple Selection

            kTrue,        // Allow children from multiple parents to be selected

            kTrue,        // Allow discontiguous selection

            {

            }

        )

In my dialog i see the list box containing entries 0-9. How can i remove these entries and add my own strings? In PanelTreeView and other samples i cant find a solution.

In DialogController::InitializeDialogFields I tried to init the list like this without effect:

IControlView* treeView = pPanelData->FindWidget( myListID );

InterfacePtr<ITreeViewMgr> iTreeMgr(treeView, UseDefaultIID();

iTreeMgr->ClearTree(kTrue);


Is treeview in cs6 the only possiblity for creating a listbox with selectable entries? A Dropdownlist is no option because user must see multipe entries after opening dialog.

This topic has been closed for replies.
Correct answer T. Schneider

NodeID node = treeviewHierarchyAdapter->GetNthChild(rootNode,0)

treeviewController->Select(node, kTrue, kTrue);

1 reply

Inspiring
December 2, 2013

Take a look at the wlistboxcomposite example. It has a IStringListData interface on the tree view for holding the strings to be drawn in the list. Update this and call ChangeRoot(). Note also that there is aare simplified List versions of the treeviewwidgets classes, like ListTreeViewAdapter

Bazinga83Author
Participant
January 8, 2014

Thanks i got it to work. But one more question:

I want the first entry in list to be selected. How can i do this?

T. SchneiderCorrect answer
Inspiring
January 8, 2014

NodeID node = treeviewHierarchyAdapter->GetNthChild(rootNode,0)

treeviewController->Select(node, kTrue, kTrue);