C2025-023 - Electronic Procedures - Modifications to PROMS (checkin 4 - added some comments)
This commit is contained in:
parent
d392131005
commit
9fdbdb05f4
@ -7,6 +7,8 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace Volian.Controls.Library
|
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 partial class ListBoxMulti : ListBox
|
||||||
{
|
{
|
||||||
public ListBoxMulti()
|
public ListBoxMulti()
|
||||||
@ -19,8 +21,13 @@ namespace Volian.Controls.Library
|
|||||||
Disposed += ListBoxMulti_Disposed;
|
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; }
|
public int singleselectedindex { get; set; }
|
||||||
|
|
||||||
private void lb_SelectedIndexChanged(object sender, EventArgs e)
|
private void lb_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ListBoxMulti tmp = (ListBoxMulti)sender;
|
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)
|
private void ListBoxMulti_Disposed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
SelectedIndexChanged -= lb_SelectedIndexChanged;
|
SelectedIndexChanged -= lb_SelectedIndexChanged;
|
||||||
|
@ -168,6 +168,7 @@ namespace Volian.Controls.Library
|
|||||||
|
|
||||||
foreach (KeyValuePair<string, ListBoxMulti> pair in _DicMultiRO)
|
foreach (KeyValuePair<string, ListBoxMulti> pair in _DicMultiRO)
|
||||||
{
|
{
|
||||||
|
//clear all items at start in case items were autoselected - bug in Winforms ListBox
|
||||||
pair.Value.ClearSelected();
|
pair.Value.ClearSelected();
|
||||||
string val = MyConfig.GetValue("EP", pair.Key);
|
string val = MyConfig.GetValue("EP", pair.Key);
|
||||||
if (val != null && val != "")
|
if (val != null && val != "")
|
||||||
@ -180,6 +181,10 @@ namespace Volian.Controls.Library
|
|||||||
pair.Value.SetSelected(pair.Value.FindString(text), true);
|
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;
|
pair.Value.singleselectedindex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user