The below code does not fire the event when I add a row
to the table on the form.
Is there an issue with static variable's events ?
If I attach and handler on the form, it works, but i dont
want to do it on every form, i want to do it in my class
with the static dataset in it..
Any suggestions?
---------
Public Class Test
Private Shared WithEvents _data As New dsCaptain
Public Shared ReadOnly Property Data() As dsCaptain
Get
Return _data
End Get
End Property
Private Shared Function loadCategory() As Integer
Return DataManager.adpCategory.Fill
(_data.Category)
End Function
Public Shared Function LoadCategories() As Integer
loadCategory()
AddHandler _data.Category.RowChanged, New
DataRowChangeEventHandler(AddressOf CategoriesChanged)
Return _data.cat_subCat.Count
End Function
Public Shared Sub CategoriesChanged(ByVal sender As
Object, ByVal e As System.Data.DataRowChangeEventArgs)
If e.Action = DataRowAction.Add Then
'MessageBox.Show("Category Added")
'make some calc, add a row to other tbl
'update database e.t.c.
End If
End Sub
End Class
-------
this class is called, int the form like:
---
Friend WithEvents SuperData As dsCaptain
Public Sub New()
MyBase.New()
InitializeComponent()
'------
SuperData = Business.Data
End Sub
Private Sub addRow_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles deleteRow.Click
mRow = SuperData.Category.NewRow
With mRow
.Name = "New Account"
.DateAdded = DateTime.Today
End With
SuperData.Category.AddCategoryRow(mRow)
End Sub
---