//On databinding DGV clears selecting or passes the appointmentID from constructor to the Indicator private void AppointmentsDGV_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { if (appointmentIDPassed == null) { AppointmentsDGV.ClearSelection(); } else { AppointmentsDGV.ClearSelection(); //called 2x in code wasnt enough to make a full method when inline lambda was faster Action <string> indicator = appointmentID => { foreach (DataGridViewRow rowSearch in AppointmentsDGV.Rows) { if (rowSearch.Cells[0].Value.ToString().Equals(appointmentID)) { rowSearch.Selected = true; AppIndx = rowSearch.Index; AppIDTextBox.Visible = true; ApptIDLabel.Visible = true; break; } } }; indicator(appointmentIDPassed); } }
//selects new view based on combo box selection private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e) { pictureBox1.Visible = false; AppointmentsDGV.Visible = true; AppIndx = null; if (comboBox1.SelectedItem != null) { string selected = comboBox1.GetItemText(comboBox1.SelectedItem); AppointmentSelectTableLoad(selected); AppointmentsDGV.ClearSelection(); } }
private void resetButton_Click(object sender, EventArgs e) { dateTimePicker1.Value = DateTime.Now; dateTimePicker2.Value = DateTime.Now; TypeTextbox.Text = ""; AppointmentSelectTableLoad(); AppointmentsDGV.ClearSelection(); preCreatedForm = false; comboBox1.SelectedItem = null; comboBox1.Text = "-customer select-"; AppIndx = null; pictureBox1.Visible = false; AppointmentsDGV.Visible = true; }
//On databinding DGV clears selecting or passes the appointmentID from constructor to the Indicator private void AppointmentsDGV_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { if (appointmentIDPassed == null) { AppointmentsDGV.ClearSelection(); } else { AppointmentsDGV.ClearSelection(); Action <string> indicator = appointmentID => { foreach (DataGridViewRow rowSearch in AppointmentsDGV.Rows) { if (rowSearch.Cells[0].Value.ToString().Equals(appointmentID)) { rowSearch.Selected = true; AppIndx = rowSearch.Index; break; } } }; indicator(appointmentIDPassed); } }
//allows DGV sort with no row selected private void AppointmentsDGV_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { AppointmentsDGV.ClearSelection(); }