Dexter Sy

Dexter Sy

  • NA
  • 1
  • 0

Maintaining ListView selection after showing a dialog

Mar 31 2009 9:24 AM
I've tried my best but it's next to impossible to get the right search keywords for what I need.

I have a ListView on my main window. My problem is that when I launch a modal dialog, the selection on my main form's ListView is automatically deselected. When that dialog closes, the selection on the ListView isn't restored. I need to be able to maintain that selection.

I've tried some hacky fixes, like saving the selected index before opening the dialog, and then manually selecting that stored index in the ListView once the dialog is done, but it doesn't work. Apparently, there's some event that deselects the ListView item that happens after the event that restores the main window. (I've tried restoring the selection in the main window's "Activated" event, but still to no avail.)