2023-09-13 09:58:42 +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;
|
|
|
|
|
|
|
|
|
|
namespace VisualComponentsLib.CustomListBox
|
|
|
|
|
{
|
|
|
|
|
[DefaultEvent(nameof(TextChanged))]
|
2023-09-13 13:48:16 +04:00
|
|
|
|
public partial class MyListBox : UserControl
|
2023-09-13 09:58:42 +04:00
|
|
|
|
{
|
|
|
|
|
[Browsable(true)]
|
|
|
|
|
public string selectedString
|
|
|
|
|
{
|
|
|
|
|
get => listBox.SelectedItem.ToString();
|
|
|
|
|
set => listBox.SelectedItem = value;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 13:48:16 +04:00
|
|
|
|
public MyListBox()
|
2023-09-13 09:58:42 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Browsable(true)]
|
|
|
|
|
public new event EventHandler? TextChanged
|
|
|
|
|
{
|
|
|
|
|
add => listBox.Items.Add(value);
|
|
|
|
|
remove => listBox.Items.Clear();
|
|
|
|
|
}
|
2023-09-13 10:30:37 +04:00
|
|
|
|
|
|
|
|
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(textBox.Text))
|
|
|
|
|
{
|
|
|
|
|
listBox.Items.Add(textBox.Text);
|
|
|
|
|
|
|
|
|
|
textBox.Text = string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
listBox.Items.Clear();
|
|
|
|
|
}
|
2023-09-13 09:58:42 +04:00
|
|
|
|
}
|
|
|
|
|
}
|