diff --git a/WinFormSolution/Components/Components.csproj b/WinFormSolution/Components/Components.csproj
index 0d2190a..283e328 100644
--- a/WinFormSolution/Components/Components.csproj
+++ b/WinFormSolution/Components/Components.csproj
@@ -7,7 +7,7 @@
enable
True
ns.potapov
- 1.0.4
+ 1.0.5
$(VersionPrefix)
diff --git a/WinFormSolution/Components/UserControlCheckedList.cs b/WinFormSolution/Components/UserControlCheckedList.cs
index c37cf14..559789b 100644
--- a/WinFormSolution/Components/UserControlCheckedList.cs
+++ b/WinFormSolution/Components/UserControlCheckedList.cs
@@ -2,10 +2,23 @@
namespace Components
{
+ public enum Types : int
+ {
+ Exception = 0,
+ DeleteFirst = 1,
+
+ }
+
+
public partial class UserControlCheckedList : UserControl
{
public int MaxCheckedItemsCount { get; set; } = 1;
+ private Types typeOfMaxChecked = Types.DeleteFirst;
private EventHandler _onCheckedItemChangedEvent;
+ public void ChangeTypeOfMaxChecked(Types type)
+ {
+ typeOfMaxChecked = type;
+ }
public event EventHandler CheckedItemChanged
{
add
@@ -31,6 +44,25 @@ namespace Components
}
}
}
+ public List CheckedItems
+ {
+ get
+ {
+ List list = new List();
+ foreach(var item in checkedListBox.CheckedItems )
+ {
+ list.Add(item.ToString());
+ }
+ return list;
+ }
+ set
+ {
+ if (checkedListBox.Items.Contains(value))
+ {
+ checkedListBox.SetItemCheckState(checkedListBox.Items.IndexOf(value), CheckState.Checked);
+ }
+ }
+ }
public UserControlCheckedList()
{
InitializeComponent();
@@ -51,8 +83,16 @@ namespace Components
{
if (checkedListBox.CheckedItems.Count > MaxCheckedItemsCount)
{
- checkedListBox.SetItemChecked(e.Index, false);
- throw new MaxCheckedItemsCountExceedException("Превышено максимальное число выбранных элементов");
+ if (typeOfMaxChecked == Types.Exception)
+ {
+ checkedListBox.SetItemChecked(e.Index, false);
+ throw new MaxCheckedItemsCountExceedException("Превышено максимальное число выбранных элементов");
+ }
+ else if (typeOfMaxChecked == Types.DeleteFirst)
+ {
+ checkedListBox.SetItemChecked(0, false);
+ }
+
}
_onCheckedItemChangedEvent?.Invoke(sender, e);
}