Getselections() is not working properly for wxtreelistctrl sample from wxWidgets 3.0.3

我的梦境 提交于 2019-12-24 12:20:16

问题


I am building treelist project from samples folder of wxWidgets 3.0.3. After running that treelist project, I got a window, I selected 2-state-checkboxes and multiple selections from style. then I selected some of the checkboxes of that tree. when I clicked on Dumpselections from operations. Now, while debugging controller is going into OnDumpSelection(). In Ondumpselection(), getselections() is executed, here getselections should return total no of selected nodes and go into default case of switch case. Then it should execute for loop to display every selected node. But, while debugging I am not able to see proper value of numSelected. Also, for loop from default case is not executing properly. Is it a bug or I am doing some mistake?

void MyFrame::OnItemChecked(wxTreeListEvent& event)
{
    wxTreeListItem item = event.GetItem();
    wxCheckBoxState itemCheckboxState =m_treelist->GetCheckedState(item);
    m_treelist->CheckItemRecursively(item, itemCheckboxState);
 }

回答1:


Selection refers to the items being selected, and not checkboxes being checked as you seem to assume. There is no function like GetSelections() for getting all the items in the checked state because this is not often useful in practice: typically you would look at the top level item, test if it is checked, then look at its children and so on.

But you can, of course, write a GetCheckedItems() function if you need one, you just will have to use GetRootItem() and GetFirstChild() and GetNextSibling() recursively.



来源:https://stackoverflow.com/questions/46986516/getselections-is-not-working-properly-for-wxtreelistctrl-sample-from-wxwidgets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!