Link to home
Start Free TrialLog in
Avatar of capitaldev
capitaldevFlag for Ireland

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.DataGridViewCell' and 'System.Windows.Forms.DataGridViewCell' 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(hitInfo.ColumnIndex)



        ' 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
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

do you want to compare them in regards to the value or the position (row/column)

I would say you want to change to:
If Me.CurrentCell.ColumnIndex <> clickedCell.ColumnIndex Or  Me.CurrentCell.RowIndex <> clickedCell.RowIndexThen 

Open in new window


hope this helps
Avatar of capitaldev

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...
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As you are storing a reference to a cell, you can just compare the references:

If Not Object.ReferenceEquals(CurrentCell, clickedCell) Then

Open in new window

thanks