2024-09-15 21:58:20 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2024-09-15 23:31:11 +04:00
|
|
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
2024-09-15 21:58:20 +04:00
|
|
|
|
|
|
|
|
|
namespace Library14Petrushin
|
|
|
|
|
{
|
|
|
|
|
public partial class ChooseList : UserControl
|
|
|
|
|
{
|
2024-09-15 23:31:11 +04:00
|
|
|
|
public event EventHandler? SelectedValueChanged;
|
|
|
|
|
|
|
|
|
|
public string SelectedValue
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return checkedListBox1.SelectedItem?.ToString() ?? string.Empty;
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
int index = checkedListBox1.Items.IndexOf(value);
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
{
|
|
|
|
|
checkedListBox1.SelectedIndex = index;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
checkedListBox1.ClearSelected();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 21:58:20 +04:00
|
|
|
|
public ChooseList()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
2024-09-15 23:31:11 +04:00
|
|
|
|
|
|
|
|
|
public void AddItemToList(string item)
|
|
|
|
|
{
|
|
|
|
|
checkedListBox1.Items.Add(item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SelectedValueChanged?.Invoke(this, e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ClearComboBox()
|
|
|
|
|
{
|
|
|
|
|
checkedListBox1.Items.Clear();
|
|
|
|
|
}
|
2024-09-15 21:58:20 +04:00
|
|
|
|
}
|
2024-09-15 23:31:11 +04:00
|
|
|
|
}
|