private void FormStaff_Load(object sender, EventArgs e) { var list = logicP.Read(null); if (list == null) { return; } foreach (var elem in list) { comboBox.DataSource = list; comboBox.ValueMember = "Id"; comboBox.DisplayMember = "Name"; comboBox.SelectedItem = null; } if (Id.HasValue) { var model = logic.Read(new StaffBindingModel { Id = Id.Value })?[0]; if (model != null) { string[] fio = model.StaffFIO.Split(); textBoxName.Text = fio[1]; textBoxSurname.Text = fio[0]; textBoxMiddlename.Text = fio.Length > 2 ? fio[2] : ""; comboBox.SelectedItem = list.FirstOrDefault(x => x.Id == model.Id); dateTimePickerBirthday.Value = model.Birthday; dateTimePickerEmployment.Value = model.Employement; } } }
private void LoadData() { var list = logic.Read(null); if (list != null) { dataGridView.DataSource = list; dataGridView.Columns[0].Visible = false; dataGridView.Columns[5].Visible = false; dataGridView.Columns[6].Visible = false; dataGridView.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } }