Events....
This commit is contained in:
parent
fcdd0702f4
commit
5ec0cd07a7
1
CustomComponents/DropList.Designer.cs
generated
1
CustomComponents/DropList.Designer.cs
generated
@ -39,6 +39,7 @@
|
|||||||
listBox.Name = "listBox";
|
listBox.Name = "listBox";
|
||||||
listBox.Size = new Size(150, 104);
|
listBox.Size = new Size(150, 104);
|
||||||
listBox.TabIndex = 0;
|
listBox.TabIndex = 0;
|
||||||
|
listBox.SelectedValueChanged +=
|
||||||
//
|
//
|
||||||
// Frame
|
// Frame
|
||||||
//
|
//
|
||||||
|
@ -3,7 +3,22 @@
|
|||||||
public partial class Frame : UserControl
|
public partial class Frame : UserControl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private event EventHandler? _valueChanged;
|
||||||
|
|
||||||
private string? SelectedValue = string.Empty;
|
private string? SelectedValue = string.Empty;
|
||||||
|
|
||||||
|
public event EventHandler ValueChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
_valueChanged += value;
|
||||||
|
}
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
_valueChanged -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Frame()
|
public Frame()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -21,7 +36,6 @@
|
|||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
listBox.Items.Clear();
|
listBox.Items.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string? Value
|
public string? Value
|
||||||
@ -36,9 +50,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValueChanged(object sender, EventArgs e)
|
private void SelectedValue_Changed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Value = listBox.SelectedItem.ToString();
|
var element = sender as ListBox;
|
||||||
|
Value = element.Text.ToString();
|
||||||
|
_valueChanged?.Invoke(this, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,9 +2,11 @@ namespace TestForms
|
|||||||
{
|
{
|
||||||
public partial class TestFrame : Form
|
public partial class TestFrame : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
public TestFrame()
|
public TestFrame()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
listBox.ValueChanged += new EventHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearButton_Click(object sender, EventArgs e)
|
private void clearButton_Click(object sender, EventArgs e)
|
||||||
@ -15,7 +17,10 @@ namespace TestForms
|
|||||||
private void fillButton_Click(object sender, EventArgs e)
|
private void fillButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
listBox.PopulateList(new List<string> { "SILENT", "RIZZ", "BLSSDY", "YUEEJKE" });
|
listBox.PopulateList(new List<string> { "SILENT", "RIZZ", "BLSSDY", "YUEEJKE" });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user