C2025-027-Develop-a-way-to-filter-annotations-so-the-user-can-view-only-the-types-they-want-to-see-EP #544
@@ -7,6 +7,8 @@ using System.Windows.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Volian.Controls.Library
 | 
			
		||||
{
 | 
			
		||||
    //Class to handle bug in Windows WinForms ListBox
 | 
			
		||||
    // that autoselects first item when no items are selected 
 | 
			
		||||
    public partial class ListBoxMulti : ListBox
 | 
			
		||||
    {
 | 
			
		||||
        public ListBoxMulti()
 | 
			
		||||
@@ -19,8 +21,13 @@ namespace Volian.Controls.Library
 | 
			
		||||
            Disposed += ListBoxMulti_Disposed;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //singleselectedindex
 | 
			
		||||
        // will help to fix bug in Winforms ListBox
 | 
			
		||||
        // that autoselects first item when no items are selected
 | 
			
		||||
        // -1 = multi or set to this after 1st initialization
 | 
			
		||||
        // if this = 0 and only 1 item selected,
 | 
			
		||||
        // that means item was autoselected, so clear all items.
 | 
			
		||||
        public int singleselectedindex { get; set; }
 | 
			
		||||
 | 
			
		||||
        private void lb_SelectedIndexChanged(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            ListBoxMulti tmp = (ListBoxMulti)sender;
 | 
			
		||||
@@ -36,6 +43,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //remove event when get rid of object
 | 
			
		||||
        private void ListBoxMulti_Disposed(object sender, EventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            SelectedIndexChanged -= lb_SelectedIndexChanged;
 | 
			
		||||
 
 | 
			
		||||
@@ -168,6 +168,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
 | 
			
		||||
			foreach (KeyValuePair<string, ListBoxMulti> pair in _DicMultiRO)
 | 
			
		||||
			{
 | 
			
		||||
				//clear all items at start in case items were autoselected - bug in Winforms ListBox
 | 
			
		||||
				pair.Value.ClearSelected();
 | 
			
		||||
				string val = MyConfig.GetValue("EP", pair.Key);
 | 
			
		||||
				if (val != null && val != "")
 | 
			
		||||
@@ -180,6 +181,10 @@ namespace Volian.Controls.Library
 | 
			
		||||
							pair.Value.SetSelected(pair.Value.FindString(text), true);
 | 
			
		||||
						}
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				//set this to -1 after initial setting of values
 | 
			
		||||
				//this will help to fix bug in Winforms ListBox
 | 
			
		||||
				//that autoselects first item when no items are selected
 | 
			
		||||
				pair.Value.singleselectedindex = -1;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user