57 lines
1.3 KiB
C#
57 lines
1.3 KiB
C#
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 WinFormsLibrary1
|
|
{
|
|
public partial class List : UserControl
|
|
{
|
|
|
|
public List()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
public void ListSet(string[] strings)
|
|
{
|
|
foreach (string s in strings)
|
|
{
|
|
listView1.Items.Add(s);
|
|
}
|
|
}
|
|
public void ClearList()
|
|
{
|
|
listView1.Items.Clear ();
|
|
}
|
|
public string SelectedItem
|
|
{
|
|
get
|
|
{
|
|
|
|
if (listView1.SelectedItems.Count > 0) return listView1.SelectedItems[0].ToString(); else return String.Empty;
|
|
}
|
|
set
|
|
{
|
|
if(value != null && !value.Equals(String.Empty))
|
|
listView1.SelectedItems[0].Text = value;
|
|
|
|
}
|
|
}
|
|
public event EventHandler SelectedElementChange
|
|
{
|
|
add => listView1.SelectedIndexChanged += value;
|
|
remove => listView1.SelectedIndexChanged -= value;
|
|
}
|
|
}
|
|
}
|