namespace Forms { public partial class Form : System.Windows.Forms.Form { public Form() { InitializeComponent(); FillBox(); FillTextBox(); FillGrid(); } private void FillBox() { controlComboBox.ComboBoxItems.Add("Значение 1"); controlComboBox.ComboBoxItems.Add("Значение 2"); controlComboBox.ComboBoxItems.Add("Значение 3"); controlComboBox.ComboBoxItems.Add("Значение 4"); controlComboBox.SelectedItem = "dafafadsf"; } private void FillTextBox() { controlTextBox.NumPattern = @"^\+7\d{10}$"; controlTextBox.text = "+79063908075"; } private void FillGrid() { List headers = new List() { "Id", "Имя", "Фамимлия" }; List width = new List() { 100, 200, 200 }; List isVisible = new List() { true, true, true }; List props = new List() { "Id", "Name", "Surname" }; controlDataGrid.CreateColumns(3, headers, width, isVisible, props); } private void controlComboBox_ComboBoxChanged(object sender, EventArgs e) { var elem = controlComboBox.SelectedItem; MessageBox.Show($"Выбранно: {elem}"); } private void controlTextBox_CheckBoxChanged(object sender, EventArgs e) { if (controlTextBox.text == null) { MessageBox.Show($"CheckBox checked"); } else { MessageBox.Show($"CheckBox not checked"); } } private void buttonGetObj_Click(object sender, EventArgs e) { var val = controlDataGrid.GetObject(); MessageBox.Show($"{val?.Name} {val?.Surname}"); } private void buttonClear_Click(object sender, EventArgs e) { controlDataGrid.ClearData(); } private void buttonEnter_Click(object sender, EventArgs e) { var val = controlTextBox.text; MessageBox.Show($"Введено {val}"); } private void buttonAdd_Click(object sender, EventArgs e) { controlDataGrid.SetData(new Person(1, "asdasdas", "asdasd1asd"), 2, 3); } } }