2023-10-06 02:36:27 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace ViewComponents
|
|
|
|
|
{
|
|
|
|
|
public partial class List_with_choice : UserControl
|
|
|
|
|
{
|
|
|
|
|
public List_with_choice()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public event Action<string?> SelectedItemChange;
|
|
|
|
|
|
|
|
|
|
public string? Element
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (checkedListBox1.SelectedItem != null) return checkedListBox1.SelectedItem.ToString();
|
|
|
|
|
else return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value != null && checkedListBox1.Items.Contains(value)) checkedListBox1.SelectedItem = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Fill_List(string str) //метод заполнения списка
|
|
|
|
|
{
|
|
|
|
|
if (str == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-15 20:05:17 +04:00
|
|
|
|
checkedListBox1.Items.Add(str);
|
2023-10-06 02:36:27 +04:00
|
|
|
|
}
|
|
|
|
|
public void Clean_List() //метод очистки списка
|
|
|
|
|
{
|
|
|
|
|
checkedListBox1.Items.Clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SelectedItemChange?.Invoke(checkedListBox1.SelectedItem.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|