Beispiel #1
0
 //Method to add data from datagrid row to corresponding textboxes
 private void InitItems()
 {
     try
     {
         employeeIDTextBox.Text    = dataGridHours[0, 0].Value.ToString();
         ActivityIDTextBox.Text    = dataGridHours[1, 0].Value.ToString();
         dateTextBox.Text          = dataGridHours[2, 0].Value.ToString();
         durationTextBox.Text      = dataGridHours[3, 0].Value.ToString();
         locationTextBox.Text      = dataGridHours[4, 0].Value.ToString();
         hoursApprovedTextBox.Text = dataGridHours[5, 0].Value.ToString();
         descriptionTextBox.Text   = dataGridHours[6, 0].Value.ToString();
         IDTextBox.Text            = dataGridHours[7, 0].Value.ToString();
     }
     catch
     {
         employeeIDTextBox.Clear();
         ActivityIDTextBox.Clear();
         dateTextBox.Clear();
         durationTextBox.Clear();
         locationTextBox.Clear();
         descriptionTextBox.Clear();
         hoursApprovedTextBox.Clear();
         IDTextBox.Clear();
     }
 }
Beispiel #2
0
 //Method to edit data in textboxes automatically if datagrid selection changes
 private void dataGridHours_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         employeeIDTextBox.Text    = dataGridHours[0, e.RowIndex].Value.ToString();
         ActivityIDTextBox.Text    = dataGridHours[1, e.RowIndex].Value.ToString();
         dateTextBox.Text          = dataGridHours[2, e.RowIndex].Value.ToString();
         durationTextBox.Text      = dataGridHours[3, e.RowIndex].Value.ToString();
         locationTextBox.Text      = dataGridHours[4, e.RowIndex].Value.ToString();
         hoursApprovedTextBox.Text = dataGridHours[5, e.RowIndex].Value.ToString();
         descriptionTextBox.Text   = dataGridHours[6, e.RowIndex].Value.ToString();
         IDTextBox.Text            = dataGridHours[7, e.RowIndex].Value.ToString();
     }
     catch
     {
         employeeIDTextBox.Clear();
         ActivityIDTextBox.Clear();
         dateTextBox.Clear();
         durationTextBox.Clear();
         locationTextBox.Clear();
         descriptionTextBox.Clear();
         hoursApprovedTextBox.Clear();
     }
 }