C2025-023 - Electronic Procedures - Modifications to PROMS (checkin #3 - fix winforms select first item bug in listboxes)
This commit is contained in:
parent
389b9e382b
commit
d392131005
44
PROMS/Volian.Controls.Library/ListBoxMulti.cs
Normal file
44
PROMS/Volian.Controls.Library/ListBoxMulti.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Volian.Controls.Library
|
||||||
|
{
|
||||||
|
public partial class ListBoxMulti : ListBox
|
||||||
|
{
|
||||||
|
public ListBoxMulti()
|
||||||
|
{
|
||||||
|
Visible = true;
|
||||||
|
SelectionMode = SelectionMode.MultiSimple;
|
||||||
|
|
||||||
|
SelectedIndexChanged += lb_SelectedIndexChanged;
|
||||||
|
|
||||||
|
Disposed += ListBoxMulti_Disposed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int singleselectedindex { get; set; }
|
||||||
|
|
||||||
|
private void lb_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ListBoxMulti tmp = (ListBoxMulti)sender;
|
||||||
|
|
||||||
|
if (tmp.SelectedItems.Count == 1 && tmp.singleselectedindex == 0)
|
||||||
|
{
|
||||||
|
tmp.ClearSelected();
|
||||||
|
}
|
||||||
|
else if (tmp.SelectedItems.Count == 1)
|
||||||
|
tmp.singleselectedindex = tmp.SelectedIndex;
|
||||||
|
else
|
||||||
|
tmp.singleselectedindex = -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ListBoxMulti_Disposed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedIndexChanged -= lb_SelectedIndexChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -280,6 +280,9 @@
|
|||||||
<DependentUpon>ImageItem.cs</DependentUpon>
|
<DependentUpon>ImageItem.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="LinkText.cs" />
|
<Compile Include="LinkText.cs" />
|
||||||
|
<Compile Include="ListBoxMulti.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="PreviewMultiLineRO.cs">
|
<Compile Include="PreviewMultiLineRO.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -24,7 +24,7 @@ namespace Volian.Controls.Library
|
|||||||
private Dictionary<string, CheckBox> _DicCheckBox;
|
private Dictionary<string, CheckBox> _DicCheckBox;
|
||||||
private Dictionary<string, ComboBox> _DicComboBox;
|
private Dictionary<string, ComboBox> _DicComboBox;
|
||||||
private Dictionary<string, ComboBox> _DicSingleRO;
|
private Dictionary<string, ComboBox> _DicSingleRO;
|
||||||
private Dictionary<string, ListBox> _DicMultiRO;
|
private Dictionary<string, ListBoxMulti> _DicMultiRO;
|
||||||
|
|
||||||
private string multiseparator = ",";
|
private string multiseparator = ",";
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ namespace Volian.Controls.Library
|
|||||||
_DicCheckBox = new Dictionary<string, CheckBox>();
|
_DicCheckBox = new Dictionary<string, CheckBox>();
|
||||||
_DicComboBox = new Dictionary<string, ComboBox>();
|
_DicComboBox = new Dictionary<string, ComboBox>();
|
||||||
_DicSingleRO = new Dictionary<string, ComboBox>();
|
_DicSingleRO = new Dictionary<string, ComboBox>();
|
||||||
_DicMultiRO = new Dictionary<string, ListBox>();
|
_DicMultiRO = new Dictionary<string, ListBoxMulti>();
|
||||||
InitializeSpecificControls(currAnn);
|
InitializeSpecificControls(currAnn);
|
||||||
_MyStepTabRibbon = new StepTabRibbon();
|
_MyStepTabRibbon = new StepTabRibbon();
|
||||||
}
|
}
|
||||||
@ -138,16 +138,12 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
if (EP.type.ToLower() == "romulti")
|
if (EP.type.ToLower() == "romulti")
|
||||||
{
|
{
|
||||||
ListBox lb = new ListBox();
|
ListBoxMulti lb = new ListBoxMulti();
|
||||||
lb.Visible = true;
|
|
||||||
|
|
||||||
List<ROListItem> tmps = EP.getROList(currAnn, false);
|
List<ROListItem> tmps = EP.getROList(currAnn, false);
|
||||||
lb.DisplayMember = "Text";
|
lb.DisplayMember = "Text";
|
||||||
lb.ValueMember = "Value";
|
lb.ValueMember = "Value";
|
||||||
|
|
||||||
lb.Width = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).First().Text, lb.Font).Width + SystemInformation.VerticalScrollBarWidth;
|
lb.Width = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).First().Text, lb.Font).Width + SystemInformation.VerticalScrollBarWidth;
|
||||||
lb.SelectionMode = SelectionMode.MultiSimple;
|
|
||||||
//lb.IsSynchronizedWithCurrentItem = false;
|
|
||||||
|
|
||||||
lb.DataSource = tmps;
|
lb.DataSource = tmps;
|
||||||
_DicMultiRO.Add(EP.name, lb);
|
_DicMultiRO.Add(EP.name, lb);
|
||||||
@ -170,7 +166,7 @@ namespace Volian.Controls.Library
|
|||||||
pair.Value.SelectedValue = -1;
|
pair.Value.SelectedValue = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (KeyValuePair<string, ListBox> pair in _DicMultiRO)
|
foreach (KeyValuePair<string, ListBoxMulti> pair in _DicMultiRO)
|
||||||
{
|
{
|
||||||
pair.Value.ClearSelected();
|
pair.Value.ClearSelected();
|
||||||
string val = MyConfig.GetValue("EP", pair.Key);
|
string val = MyConfig.GetValue("EP", pair.Key);
|
||||||
@ -184,7 +180,10 @@ namespace Volian.Controls.Library
|
|||||||
pair.Value.SetSelected(pair.Value.FindString(text), true);
|
pair.Value.SetSelected(pair.Value.FindString(text), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
pair.Value.singleselectedindex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FieldStepRTB_Enter(object sender, EventArgs e)
|
private void FieldStepRTB_Enter(object sender, EventArgs e)
|
||||||
@ -246,7 +245,7 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
else if (EP.type.ToLower() == "romulti")
|
else if (EP.type.ToLower() == "romulti")
|
||||||
{
|
{
|
||||||
ListBox lbcur = _DicMultiRO[EP.name];
|
ListBoxMulti lbcur = _DicMultiRO[EP.name];
|
||||||
string newvalues = String.Join(multiseparator, lbcur.SelectedItems.OfType<ROListItem>().Select(item => item.Value));
|
string newvalues = String.Join(multiseparator, lbcur.SelectedItems.OfType<ROListItem>().Select(item => item.Value));
|
||||||
string oldvalues = MyConfig.GetValue("EP", EP.name);
|
string oldvalues = MyConfig.GetValue("EP", EP.name);
|
||||||
if (newvalues != oldvalues)
|
if (newvalues != oldvalues)
|
||||||
@ -287,6 +286,11 @@ namespace Volian.Controls.Library
|
|||||||
tb.Enter -= FieldStepRTB_Enter;
|
tb.Enter -= FieldStepRTB_Enter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (ListBoxMulti lb in _DicMultiRO.Values)
|
||||||
|
{
|
||||||
|
lb.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Load -= Form1Load_setDefaults;
|
Load -= Form1Load_setDefaults;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user