Archicad C++ API
About Archicad add-on development using the C++ API.
SOLVED!

Conditionally AppendItem in ListBox

BenjiDev
Enthusiast

Hello, 

 

I am making a trace dialog that outputs trace level, location in code and a custom message. It consists of a listbox and some checkboxes:

 

normal.png

When a checkbox is unchecked items with that trace level should not be displayed in the listbox:

 

abn.png

(The abnormal trace is removed in the above picture)

 

My problem is that it also removes every item that comes after the removed item (in the above case the removed trace was already last so the bug is not noticed). Unchecking debug removes the error and abnormal trace aswell:

 

debug.png

Which is unwanted. Only the debug trace should be removed.

 

What i do in the code is pretty simple right now: When the value of a checkbox is changed i clear the listbox and populate it again based on the value of the checkboxes. So if for example the trace level is info but that checkbox is unchecked that item won't be appended to the listbox:

redraw.png

changed.png

 

I am pretty confident that the logic in the loop is OK but i am not 100%. Any help is appretiated.

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Oleg
Expert

Also, insted index of list item, you can use DG::ListBox::BottomItem.
Like:
listBox.SetTabItemText(  DG::ListBox::BottomItem, Teb::.....)

View solution in original post

4 REPLIES 4
leilei
Enthusiast

Hi,Maybe this can help you.

1111.jpg

Solution
Oleg
Expert

Also, insted index of list item, you can use DG::ListBox::BottomItem.
Like:
listBox.SetTabItemText(  DG::ListBox::BottomItem, Teb::.....)

Thanks so much, now the error is obvious. I was setting the text on indexes that was not even rendered..

Thanks, i think this is the cleaner way.