diff --git a/samples/treectrl/treetest.cpp b/samples/treectrl/treetest.cpp index 18a5c2797a..5ae5061252 100644 --- a/samples/treectrl/treetest.cpp +++ b/samples/treectrl/treetest.cpp @@ -594,7 +594,9 @@ void MyFrame::OnDumpSelected(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnSelect(wxCommandEvent& WXUNUSED(event)) { - m_treeCtrl->SelectItem(m_treeCtrl->GetFocusedItem()); + const wxTreeItemId focus = m_treeCtrl->GetFocusedItem(); + if ( focus.IsOk() ) + m_treeCtrl->SelectItem(focus); } void MyFrame::OnSelectRoot(wxCommandEvent& WXUNUSED(event))