//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Event handler. Called by PreviousData for click events. </summary> /// /// <remarks> , 23/08/2018. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Event information. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void PreviousData_Click(object sender, EventArgs e) { try { int currentRow = MyPeopleGrid.CurrentCell.RowIndex; if (currentRow == 0) { return; } else { LastData.Enabled = true; NextData.Enabled = true; currentRow--; MyPeopleGrid.ClearSelection(); MyPeopleGrid.CurrentCell = MyPeopleGrid.Rows[currentRow].Cells[0]; MyPeopleGrid.Rows[currentRow].Selected = true; } if (currentRow == 0) { FirstData.Enabled = false; PreviousData.Enabled = false; return; } } catch { MessageBox.Show("Need data!", "Message"); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Event handler. Called by LastData for click events. </summary> /// /// <remarks> , 23/08/2018. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Event information. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void LastData_Click(object sender, EventArgs e) { try { FirstData.Enabled = true; PreviousData.Enabled = true; int currentRow = MyPeopleGrid.Rows.Count - 1; MyPeopleGrid.ClearSelection(); MyPeopleGrid.CurrentCell = MyPeopleGrid.Rows[currentRow].Cells[0]; MyPeopleGrid.Rows[currentRow].Selected = true; if (currentRow == -1) { return; } else { LastData.Enabled = false; NextData.Enabled = false; } } catch (Exception) { MessageBox.Show("Need data!", "Message"); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Event handler. Called by MyPeopleGrid for select events. </summary> /// /// <remarks> , 23/08/2018. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Data grid view cell event information. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void MyPeopleGrid_Select(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { DataGridViewRow row = this.MyPeopleGrid.Rows[e.RowIndex]; personName.Text = row.Cells["Person"].Value.ToString(); like.Text = row.Cells["Likes"].Value.ToString(); dislike.Text = row.Cells["Dislikes"].Value.ToString(); dayDay.Text = row.Cells["Day"].Value.ToString(); dayMonth.Text = row.Cells["Month"].Value.ToString(); } } catch (Exception) { MyPeopleGrid.ClearSelection(); } }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> Event handler. Called by BirthdayMonth for text changed events. </summary> /// /// <remarks> , 23/08/2018. </remarks> /// /// <param name="sender"> Source of the event. </param> /// <param name="e"> Event information. </param> //////////////////////////////////////////////////////////////////////////////////////////////////// private void BirthdayMonth_TextChanged(object sender, EventArgs e) { MyPeopleGrid.SelectAll(); BirthdaysGrid.Sort(BirthdaysGrid.Columns["pDays"], ListSortDirection.Ascending); try { foreach (DataGridViewRow row in BirthdaysGrid.Rows) { // Test if the first column of the current row equals // the value in the text box if ((string)row.Cells["pMonth"].Value == BirthdayMonth.Text) { // we have a match row.Selected = false; row.Visible = true; } else { row.Selected = false; row.Visible = false; } } if (string.IsNullOrEmpty(BirthdayMonth.Text)) { MyPeopleGrid.ClearSelection(); int currentRow = MyPeopleGrid.CurrentCell.RowIndex; MyPeopleGrid.CurrentCell = MyPeopleGrid.Rows[currentRow].Cells[0]; MyPeopleGrid.Rows[currentRow].Selected = true; } else { } } catch { } }