namespace Test { public partial class FormTest : Form { private bool EmptyFill = false; readonly List students = new() { new Student { Id = 0, Surname = "Elatomtsev", Height = 195, Iq = 155 }, new Student { Id = 1, Surname = "Bakshaeva", Height = 150, Iq = 170 }, new Student { Id = 2, Surname = "Firsov", Height = 180, Iq = 100 }, new Student { Id = 3, Surname = "Razin", Height = 185, Iq = 140 }, }; readonly List items = new() { new string("item1"), new string("item2"), new string("item3"), new string("item4"), new string("item5"), new string("item6"), new string("item7"), }; public FormTest() { InitializeComponent(); CreateList(); } private void CustomListBox1_ValueChanged(object sender, EventArgs e) { MessageBox.Show($"Selected item: {customListBox1.SelectedValue}"); } private void CreateList() { customListBox1.PopulateList(items); } private void buttonClear_Click(object sender, EventArgs e) { customListBox1.ClearList(); } private void buttonLoad_Click(object sender, EventArgs e) { CreateList(); customListBox1.Refresh(); } private void buttonGetList_Click(object sender, EventArgs e) { string selectedValue = customListBox1.SelectedValue; MessageBox.Show($"Selected Value: {selectedValue}"); } private void CreateTable() { customDataGridView1.ConfigColumn(new() { ColumnsCount = 4, NameColumn = new string[] { "Id", "Surname", "Height", "Iq" }, Width = new int[] { 10, 150, 250, 200 }, Visible = new bool[] { false, true, true, true }, PropertiesObject = new string[] { "Id", "Surname", "Height", "Iq" }, }); foreach (Student student in students) { int rowIndex = customDataGridView1.Rows.Add(); for (int i = 0; i < 4; i++) { customDataGridView1.AddItem(student, rowIndex, i); } } } private void buttonClearTable_Click(object sender, EventArgs e) { customDataGridView1.ClearDataGrid(); } private void buttonTableAdd_Click(object sender, EventArgs e) { CreateTable(); } private void buttonGetValue_Click(object sender, EventArgs e) { Student selectedStudent = customDataGridView1.GetSelectedObjectInRow(); MessageBox.Show($"Selected Row Index: {customDataGridView1.SelectedRow}"); MessageBox.Show($"Selected Student: {selectedStudent}"); } private void buttonAddOneRow_Click(object sender, EventArgs e) { Student newStudent = new Student { Id = 4, Surname = "New Student", Height = 185, Iq = 125 }; int rowIndex = customDataGridView1.Rows.Add(); for (int i = 0; i < 4; i++) { customDataGridView1.AddItem(newStudent, rowIndex, i); } } private void buttonGetValueCheckBox_Click(object sender, EventArgs e) { MessageBox.Show($"Value is {dateBoxWithNull1.Value}"); } private void buttonSetDate_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBoxDate.Text)) { dateBoxWithNull1.Value = null; // Устанавливаем значение null, если textBox пуст } else if (DateTime.TryParse(textBoxDate.Text, out DateTime date)) { dateBoxWithNull1.Value = date; } } } }