2024-09-05 15:05:04 +04:00

86 lines
2.8 KiB
C#

using COP;
namespace TestsComponents
{
public partial class FormTestComponents : Form
{
public FormTestComponents()
{
InitializeComponent();
Fill();
}
public void Fill()
{
userCheckedListBox.append(new() { "items1", "dsdsf", "items3", "fgdg", "iit" });
}
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.Text = userCheckedListBox.SelectedValue;
}
private void ButtonShowDate_Click(object sender, EventArgs e)
{
try
{
textBoxShowDate.Clear();
textBoxShowDate.Text = userDateTimePicker.SelectedValue.ToString();
}
catch (Exception ex)
{
MessageBox.Show("Îøèáêà");
}
}
private void UserDateTimePicker_ValueChanged(object sender, EventArgs e)
{
MessageBox.Show("Value changed");
DateTime? selectedDate = userDateTimePicker.SelectedValue;
}
private void ButtonRangeSet_Click(object sender, EventArgs e)
{
userDateTimePicker.MaxValue = new DateTime(2024, 9, 20);
userDateTimePicker.MinValue = new DateTime(2024,8,10);
}
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; }
}
}
}