If e.ColumnIndex = 0 Then      'Delete button clicked
               'delete button clicked inside PositionDataGridView
               If sender Is interviewDataGridView Then
                   'Messagebox notifying the user they're about to delete a record
                   dlgResult = MessageBox.Show("Delete This INTERVIEW record " & interviewDataGridView.Rows(e.RowIndex).Cells(e.ColumnIndex + 1).Value.ToString _
                                       & "?", "Do you want To delete this record", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation,
                   'only delete if the user clicks 'OK'
                   If dlgResult = System.Windows.Forms.DialogResult.OK Then
                       'delete current row
                   End If
               End If
           End If
       ElseIf sender Is interviewdatagridview AndAlso e.ColumnIndex <> 0 Then
           If Not PositionCompanyBindingSource.Current Is Nothing Then
               drPC = (PositionCompanyBindingSource.Current).row
               drCom = drPC.GetParentRow("FK_PositionCompany_Company")
               drPos = drPC.GetParentRow("FK_PositionCompany_Position")
           Else drPC = Nothing
           End If
           If drPC Is Nothing Then
               PosTextBox.Text = ""
               ComTextBox.Text = ""
               PosTextBox.Text = drPos.Title.ToString
               ComTextBox.Text = drCom.Name.ToString
           End If
       End If
Click image for larger version. 

Name:	incap.JPG 
Views:	2 
Size:	33.3 KB 
ID:	16653