SysTryReturnResult(NID_UI_CTRL, (__pOptionMenu->GetItemCount() > 0), E_SYSTEM,
"A system error has occurred. No items exists.");
- __pOptionMenu->GetScrollPanel()->DetachAllChildren();
+ result r = E_SUCCESS;
+ _OptionMenuItem* pItem = null;
+
+ for (int index = 0; index < __pOptionMenu->GetItemCount(); index++)
+ {
+ pItem = __pModel->GetItem(0);
- result r = __pModel->RemoveAllItem();
- SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to delete all items.");
+ if (pItem != null && pItem->HasParent())
+ {
+ r = __pOptionMenu->GetScrollPanel()->DetachChild(*pItem);
+ SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to detach item.");
+ }
+
+ r = __pModel->RemoveItem(0);
+ SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Failed to delete item.");
+ }
return r;
}