Component-oriented-programming/ComponentLibrary1/check_list/CheckList.cs
Zakharov_Rostislav 3ddd5b0500 feat(lab1): do lab1
task2 is complited

Some refactoring. Created folders for each components

complete task 3 (maybe)

some refactoring

some refactor

some minor fixes

minor changes

minor fixes

minor fixes
2024-09-16 14:26:15 +04:00

64 lines
1.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
namespace ComponentLibrary1
{
public partial class CheckList : UserControl
{
private event EventHandler? _сhangeEvent;
public event EventHandler ChangeEvent
{
add
{
_сhangeEvent += value;
}
remove
{
_сhangeEvent -= value;
}
}
public string SelectedItem
{
get
{
return checkedListBox.SelectedItem?.ToString() ?? string.Empty;
}
set
{
checkedListBox.SelectedIndex = checkedListBox.Items.IndexOf(value);
}
}
public CheckList()
{
InitializeComponent();
}
public void Input(string input)
{
if (string.IsNullOrEmpty(input))
throw new ArgumentNullException("input");
checkedListBox.Items.Add(input);
}
public void Clear()
{
checkedListBox.Items.Clear();
}
private void checkedListBox_SelectedIndexChanged(object sender, EventArgs e)
{
_сhangeEvent?.Invoke(this, e);
}
}
}