diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 93316cee7d..d761e0856b 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -4502,6 +4502,14 @@ void wxListMainWindow::InsertItem( wxListItem &item ) m_dirty = TRUE; + // If an item is selected at or below the point of insertion, we need to + // increment the member variables because the current row's index has gone + // up by one + if ( HasCurrent() && m_current >= id ) + { + m_current++; + } + SendNotify(id, wxEVT_COMMAND_LIST_INSERT_ITEM); RefreshLines(id, GetItemCount() - 1);