Subclassing DatagridView, onPaint event
I am subclassing DataGridView to extend and bind some common functionailty.
Here I overrides few (about 10) events and everything work OK except
onPaint event.
Code:
Imports System.ComponentModel
Public Class xDataGridView
Inherits DataGridView
Private _selected_row As Integer
Protected Overrides Sub onPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
sel_row = Me.CurrentRow.Index + 1
MyBase.OnPaint(e)
End Sub
<Browsable(True)> _
Public Property sel_row() As Integer
Get
Return _selected_row
End Get
Set(ByVal Value As Integer)
_selected_row = Value
End Set
End Property
End Class
In main form which contains this class under _Paint event handler I would
like to get selected row as common property: mySel_row = myDGV.sel_row
When I try to open designer for main form in VBIDE on place of DGV is big
red 'X' with red border.
System.NullReferenceException: Object reference not set to an instance of
an object.
But if I start a program it works normally. All other events from this
class also work normally and doesn't report that.
What may be a cause of this error?
No comments:
Post a Comment