capitaldev
asked on
Operator '<>' is not defined for types 'System.Windows.Forms.DataGridViewCell' and 'System.Windows.Forms.DataGridViewCell'
Hi
I'm trying to compile a bit of code that allows one click edit of a DatagridView. It inherits the the DataGridView class. However when I compile it I get the error
Operator '<>' is not defined for types 'System.Windows.Forms.Data GridViewCe ll' and 'System.Windows.Forms.Data GridViewCe ll' in the MouseDown Routine as below. I have also attached the whole class. Basically i would like the class to compile.
' Get clicked cell
Dim clickedCell As DataGridViewCell = Me.Rows(hitInfo.RowIndex). Cells(hitI nfo.Column Index)
' If cell not current, try and make it so
' **** error occurs here *************
If CurrentCell <> clickedCell Then
' Allow standard processing make clicked cell current
MyBase.OnMouseDown(e)
' If this didn't happen (validation failed etc), abort
If Me.CurrentCell <> clickedCell Then
Return
End If
End If
'whole class file below
'------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- -------
OneClickEditDataGrid.vb
I'm trying to compile a bit of code that allows one click edit of a DatagridView. It inherits the the DataGridView class. However when I compile it I get the error
Operator '<>' is not defined for types 'System.Windows.Forms.Data
' Get clicked cell
Dim clickedCell As DataGridViewCell = Me.Rows(hitInfo.RowIndex).
' If cell not current, try and make it so
' **** error occurs here *************
If CurrentCell <> clickedCell Then
' Allow standard processing make clicked cell current
MyBase.OnMouseDown(e)
' If this didn't happen (validation failed etc), abort
If Me.CurrentCell <> clickedCell Then
Return
End If
End If
'whole class file below
'-------------------------
OneClickEditDataGrid.vb
ASKER
Thanks, I was thinking along the lines of creating an operating for it some how
Public shared Operater(datagridcell a, datagridcell b) as boolean
If A.ColumnIndex <> B.ColumnIndex Or A.CurrentCell.RowIndex <> B.Rowindex
end operator
but a get a compile error when i do this...
Also I thought I may be missing a reference or something...
Public shared Operater(datagridcell a, datagridcell b) as boolean
If A.ColumnIndex <> B.ColumnIndex Or A.CurrentCell.RowIndex <> B.Rowindex
end operator
but a get a compile error when i do this...
Also I thought I may be missing a reference or something...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As you are storing a reference to a cell, you can just compare the references:
If Not Object.ReferenceEquals(CurrentCell, clickedCell) Then
ASKER
thanks
I would say you want to change to:
Open in new window
hope this helps