Public Sub LoadDataAS()
grdApplicantsAS.DataSource = Nothing
grdApplicantsAS.Columns.Clear()
txtSearchBar1.Clear()
mycom.Connection = cn
mycom.CommandText = "SELECT concat_ws(',', LastName, FirstName, MiddleName) as 'Applicant Name',EDate as 'Date of Examination', EScore as 'Examination Score', IStatus as 'Interview Status',IComment as 'Interview Comment' FROM tbl_applicant"
Dim myadap As New MySqlDataAdapter(mycom)
Dim mydt As New DataTable
myadap.Fill(mydt)
grdApplicantsAS.DataSource = mydt
Dim buttonColumn As New DataGridViewButtonColumn()
buttonColumn.HeaderText = ""
buttonColumn.Name = "Status Request"
buttonColumn.Text = "Hire"
buttonColumn.UseColumnTextForButtonValue = True
grdApplicantsAS.Columns.Add(buttonColumn)
Dim buttonColumn1 As New DataGridViewButtonColumn()
buttonColumn1.HeaderText = ""
buttonColumn1.Name = "Status Request"
buttonColumn1.Text = "Regrets"
buttonColumn1.UseColumnTextForButtonValue = True
grdApplicantsAS.Columns.Add(buttonColumn1)
myadap.Dispose()
mydt.Dispose()
End Sub
我的数据表的每一行都分别有两个按钮租用和遗憾,我的数据表的一列包含电话号码,我无法弄清楚,如果我如何得到同一行的数字,我点击按钮租用并通过它是另一种形式..非常感谢任何帮助
答案 0 :(得分:2)
要执行此操作,您可以使用CellClick
的{{1}}事件,请参阅下文。
DataGridView
表格2示例
Private Sub grdApplicantsAS_CellClick(sender As Object, e As DataGridViewCellEventArgs) Handles grdApplicantsAS.CellClick
Dim frm2 As Form2
Try
'First column button
If e.ColumnIndex = 0 Then
frm2 = New Form2(grdApplicantsAS.CurrentRow.Cells(YOUR NUMBER COLUMN).Value.ToString())
frm2.ShowDialog()
ElseIf e.ColumnIndex = 1
'Do what you need here for the other button...
End If
Catch ex As Exception
End Try
End If
End Sub