int KGLISTITEMDATELINK::FindItemByText(CString szItemText, LPKGLISTITEM pStartItem) { int nResult = false; int nRetCode = false; INT_PTR nSubItemCount = 0; INT_PTR i = 0; KG_PROCESS_ERROR(szItemText != ""); KG_PROCESS_ERROR(pStartItem); nSubItemCount = pStartItem->arryItemText.GetCount(); for (i = 0; i < nSubItemCount; i++) { if (pStartItem->arryItemText.GetAt(i).szItemText.Find(szItemText) != -1) { arrayFindedItem.Add(pStartItem); break; } } FindItemByText(szItemText, pStartItem->pFirstChildItem); FindItemByText(szItemText, pStartItem->pNexSiblingItem); nResult = true; Exit0: return nResult; }
virtual void SetStringValue( const wxString& s ) { wxTreeItemId root = GetRootItem(); if ( !root.IsOk() ) return; wxTreeItemId found = FindItemByText(root,s); if ( found.IsOk() ) { m_value = m_itemHere = found; wxTreeCtrl::SelectItem(found); } }
// Needed by SetStringValue wxTreeItemId FindItemByText( wxTreeItemId parent, const wxString& text ) { wxTreeItemIdValue cookie; wxTreeItemId child = GetFirstChild(parent,cookie); while ( child.IsOk() ) { if ( GetItemText(child) == text ) { return child; } if ( ItemHasChildren(child) ) { wxTreeItemId found = FindItemByText(child,text); if ( found.IsOk() ) return found; } child = GetNextChild(parent,cookie); } return wxTreeItemId(); }