Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27189

Disable DGV row click unless if command is met

$
0
0
i am trying to work out how to not allow users to select a databound DGV row unless an if command is met

i know how to achieve this using CellClick i.e

Code:


    Private Sub ProfilesDataGridView_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles ProfilesDataGridView.CellClick

        If NewActive = 0 Then
            Try
                Me.FilesTableAdapter.NewProfile(Me.FilesDataSet.Files, Prifle_NameTextBox.Text)
            Catch ex As System.Exception
                System.Windows.Forms.MessageBox.Show(ex.Message)
            End Try

        Else

            MsgBox("You need to save the current profile before you can navigate away.", MsgBoxStyle.Exclamation)

        End If

    End Sub

BUT the DGV still selects the row that the user clicked on How can i make it so when the user clicks on ok the DGV will return to the Row that was being edited before the user attempted to click a new row


i hope that makes sense

Viewing all articles
Browse latest Browse all 27189

Trending Articles