84 lines
2.7 KiB
C#
84 lines
2.7 KiB
C#
namespace TestComponents
|
||
{
|
||
public partial class FormTestComponents : Form
|
||
{
|
||
public FormTestComponents()
|
||
{
|
||
InitializeComponent();
|
||
Fill();
|
||
}
|
||
|
||
private void Fill()
|
||
{
|
||
List<string> items = new() { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
|
||
userCheckedListBox.FillList(items);
|
||
}
|
||
|
||
private void UserCheckedListBox_SelectedValueChanged(object sender, EventArgs e)
|
||
{
|
||
MessageBox.Show("Selected value changed");
|
||
}
|
||
|
||
private void ButtonClear_Click(object sender, EventArgs e)
|
||
{
|
||
userCheckedListBox.ClearList();
|
||
}
|
||
|
||
private void ButtonShowItems_Click(object sender, EventArgs e)
|
||
{
|
||
textBoxItems.Clear();
|
||
textBoxItems.Text = userCheckedListBox.SelectedValue;
|
||
}
|
||
|
||
private void ButtonShowDate_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
textBoxShowDate.Clear();
|
||
textBoxShowDate.Text = userDateTimePicker.SelectedValue.ToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show(ex.Message);
|
||
}
|
||
}
|
||
|
||
private void UserDateTimePicker_ValueChanged(object sender, EventArgs e)
|
||
{
|
||
MessageBox.Show("Value changed");
|
||
DateTime? selectedDate = userDateTimePicker.SelectedValue;
|
||
}
|
||
|
||
private void UserTreeView_Load(object sender, EventArgs e)
|
||
{
|
||
List<Employee> employees = new List<Employee>
|
||
{
|
||
new Employee { Department = "Отдел1", Position = "Должность1", Name = "Сотрудник1" },
|
||
new Employee { Department = "Отдел2", Position = "Должность2", Name = "Сотрудник2" },
|
||
new Employee { Department = "Отдел1", Position = "Должность1", Name = "Сотрудник3" },
|
||
new Employee { Department = "Отдел2", Position = "Должность3", Name = "Сотрудник4" },
|
||
};
|
||
var Hierarchy = new List<string> { "Department", "Position", "Name" };
|
||
foreach (var prop in employees[0].GetType().GetProperties())
|
||
{
|
||
userTreeView.Hierarchy.Add(prop.Name);
|
||
}
|
||
|
||
try
|
||
{
|
||
userTreeView.PopulateTree(employees);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
MessageBox.Show(ex.Message);
|
||
}
|
||
}
|
||
|
||
public class Employee
|
||
{
|
||
public string? Department { get; set; }
|
||
public string? Position { get; set; }
|
||
public string? Name { get; set; }
|
||
}
|
||
}
|
||
} |