I'm trying to validate that a particular column in a datagridview has been selected.
I've created this code which transfers the value of the selected Customer ID cell in the datagridview to another form.
Private Sub mnuFileEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileEdit.Click
'Define variable for the current selected cell value
strSelectedCustomerID = dgvCustomerSearch.CurrentCell.Value.ToString()
'Define the new form and transfer the selected customer ID value to it
Dim customerEditForm As New frmCustomerEdit
customerEditForm.lblCustomerPK.Text = strSelectedCustomerID
customerEditForm.ShowDialog()
It's working fine but at the moment any column in the datagridview can be selected and transferred which causes an error.
So I want to create an If Then statement which confirms that the selected column with the dgv is the PK_ID (customer ID) column before processing the rest of the code. I've tried playing around with "If dgvCustomerSearch.SelectedColumns("PK_ID") Then" but a "Value of type...cannot be converted to Integer" error occurs.
I'd appreciate if you could let me know the correct coding.
Thanks, Kevin
I've created this code which transfers the value of the selected Customer ID cell in the datagridview to another form.
Private Sub mnuFileEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileEdit.Click
'Define variable for the current selected cell value
strSelectedCustomerID = dgvCustomerSearch.CurrentCell.Value.ToString()
'Define the new form and transfer the selected customer ID value to it
Dim customerEditForm As New frmCustomerEdit
customerEditForm.lblCustomerPK.Text = strSelectedCustomerID
customerEditForm.ShowDialog()
It's working fine but at the moment any column in the datagridview can be selected and transferred which causes an error.
So I want to create an If Then statement which confirms that the selected column with the dgv is the PK_ID (customer ID) column before processing the rest of the code. I've tried playing around with "If dgvCustomerSearch.SelectedColumns("PK_ID") Then" but a "Value of type...cannot be converted to Integer" error occurs.
I'd appreciate if you could let me know the correct coding.
Thanks, Kevin