I'm converting C# code to VB.Net and I completed everything but a couple
lines. I'm receiving an error Calling Public Event directly. Here is the
relevant code:
Public Class DataGridButtonColumns
Inherits DataGridTextBoxColumn
Public Event CellButtonClicked As DataGridCellButtonClickEventHandler
Private _button As Bitmap
Private _buttonPressed As Bitmap
Private _columnNum As Integer
Private _pressedRow As Integer
Public Sub HandleMouseUp(ByVal sender As Object, ByVal e As
MouseEventArgs)
Dim dg As DataGrid = Me.DataGridTableStyle.DataGrid
Dim hti As DataGrid.HitTestInfo = dg.HitTest(New Point(e.X, e.Y))
Dim isClickInCell As Boolean
If (hti.Column = Me._columnNum) And (hti.Row > -1) Then
isClickInCell = True
Else
isClickInCell = False
End If
_pressedRow = -1
Dim rect As Rectangle = New Rectangle(0, 0, 0, 0)
If isClickInCell = True Then
rect = dg.GetCellBounds(hti.Row, hti.Column)
isClickInCell = (e.X > rect.Right - Me._button.Width)
End If
If isClickInCell = True Then
Dim g As Graphics = Graphics.FromHwnd(dg.Handle)
DrawButton(g, Me._button, rect, hti.Row)
g.Dispose()
'Working C# Code
'if(CellButtonClicked != null)
' CellButtonClicked(this, new
DataGridCellButtonClickEventArgs(hti.Row, hti.Column));
'Code causing error:
If Not CellButtonClicked Is Nothing Then
CellButtonClicked(Me, New
DataGridCellButtonClickEventArgs(hti.Row, hti.Column))
End If
End If
End Sub
Thanks.
Josh.