[RESOLVED] Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
I have various routines that are executed when you click in a particular cell, how do i prevent the routines from executing when i click on the select row button on the far left of the DGV?
http://img713.imageshack.us/img713/5726/7kam.jpg
regards
toe
Re: Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
All the cell-related events of the DataGridView provide a ColumnIndex and a RowIndex. You test the ColumnIndex and don't do anything unless its the index of a column for which you want to do some processing.
Re: Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
Are you using CellContentClick or Mouse Events? the arguments are a bit different on either one
Re: Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
DataGridView.CellEnter
since you mentioned it i did try "DataGridView.MouseEnter" but pretty much the same result
Code:
Private Sub PaymentsDataGridView_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles PaymentsDataGridView.MouseEnter
If PaymentsDataGridView.CurrentRow.Cells(2).Selected Then
paymentsDescriptions.Show()
End If
End Sub
Re: Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
Odd, cellEnter should not be triggered when you select the row headers.
Re: Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
This seems to be the event to use
Code:
Private Sub PaymentsDataGridView_CellContentClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles PaymentsDataGridView.CellContentClick
*EDIT
incorrect as will not fire cell events when there is no content in the cell :(
Re: Prevent DataGridView Select Row From Executing Cell Mouse Click Routines
got it with this
Code:
If PaymentsDataGridView.CurrentCell.ColumnIndex = (2) Then
Dim intCurrentCol2 As Integer = Nothing
Dim intCurrentRow2 As Integer = Nothing
intCurrentCol2 = PaymentsDataGridView.CurrentCell.ColumnIndex
intCurrentRow2 = PaymentsDataGridView.CurrentCell.RowIndex
PaymentsDataGridView.Rows(intCurrentRow2).Cells(intCurrentCol2).Selected = True
paymentsDescriptions.Show()
End If