From 481ddc01219c484dfccbba5a3de3dac2db81bc96 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Mon, 1 Oct 2018 15:10:51 -0500 Subject: [PATCH] fix the selection jumping bug --- EduNetworkBuilder/ListBoxWindow.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/EduNetworkBuilder/ListBoxWindow.cs b/EduNetworkBuilder/ListBoxWindow.cs index 1117869..d25df83 100644 --- a/EduNetworkBuilder/ListBoxWindow.cs +++ b/EduNetworkBuilder/ListBoxWindow.cs @@ -261,6 +261,8 @@ namespace EduNetworkBuilder { int selectedIndex = lbWindowData.SelectedIndex; string selected = ""; + int topmost = lbWindowData.TopIndex; + int totalcount = lbWindowData.Items.Count; if (lbWindowData.SelectedIndex != -1) selected = lbWindowData.Items[lbWindowData.SelectedIndex].ToString(); lbWindowData.Items.Clear(); @@ -382,7 +384,10 @@ namespace EduNetworkBuilder if(selected != null && selected != "") { if (selectedIndex >= 0 && selectedIndex < lbWindowData.Items.Count) + { lbWindowData.SelectedIndex = selectedIndex; + lbWindowData.TopIndex = topmost; + } } if(lbWindowData.SelectedIndex != -1) { @@ -454,8 +459,11 @@ namespace EduNetworkBuilder } if (selected != null && selected != "") { - if(selectedIndex >=0 && selectedIndex < lbWindowData.Items.Count) + if (selectedIndex >= 0 && selectedIndex < lbWindowData.Items.Count) + { lbWindowData.SelectedIndex = selectedIndex; + lbWindowData.TopIndex = topmost; + } } if (lbWindowData.SelectedIndex != -1) {