Noob with Event Help please

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, i am totaly new with Event in VB.net.
So : my project :
One class with a lot of collection.
I have a MDIFORM for show all stuff inside this class.
so in the class if i add a new object in a collection (ex : block) if want to raise a event .
The Child Form receive this event and adjust the data.
So for this my code :
Inside my class :
'------------------------------------------------------------------------- '------ Ajout d'un Bloc -------------------------------------------------- '------------------------------------------------------------------------- ' ENTREE ' DefBloc : La référence du bloc à traiter (ObjectId) ' SORTIE ' Le pointeur du nouveau Bloc '------------------------------------------------------------------------- Public Function AddBloc(ByRef DefBloc As Object, ByVal Debug As Boolean) As ClassDef0f_Bloc Dim DefRetour As ClassDef0f_Bloc DefRetour = New ClassDef0f_Bloc(DefBloc(GestionAUTOCAD.Enum_GA_GSFB.Nom)) If DefRetour.ExtractionAtt(DefBloc, Debug) = True Then Try 'ajout à la collection DefRetour.ClassBase = Me cCollBloc.Add(DefRetour, DefRetour.Nom) 'MaJ des FenetreConfig RaiseEvent EventBlocNew(DefRetour.Nom) Return DefRetour Catch ex As Exception 'erreur car déjà existant DefRetour.Dispose() DefRetour = Nothing MsgBox("Ce nom de bloc existe déjà !", MsgBoxStyle.Information, "Erreur Utilisateur") Return Nothing End Try Else 'erreur à la création DefRetour.Dispose() DefRetour = Nothing MsgBox("Erreur à l'extraction des attributs", MsgBoxStyle.Information, "Erreur Systeème") Return Nothing End If End Function
--> i raise the évent EventBlocNew
this event is : Shared Event EventBlocNew(ByVal Nom As String) in this class
So in my form :
in the new : AddHandler ClassDef0_StyleGeneral.EventBoiteOpNew, AddressOf EventBoiteOpNew
in the finalize : RemoveHandler ClassDef0_StyleGeneral.EventBoiteOpNew, AddressOf EventBoiteOpNew
i retrieve the event :
Protected Sub EventBlocNew(ByVal Nom As String)
Dim columnB As Windows.Forms.DataGridViewComboBoxColumn = Nothing
columnB= DataGridViewCalque.Columns(EnumCalque.Bloc)
columnB.Items.Remove(Nom)
End Sub
so all my code woks fine in the fist loaded project (in autocad) but when i quit and launch this the code in Protected Sub EventBlocNew(ByVal Nom As String) crash..
--> Windows.Forms.DataGridViewComboBoxColumn --> 0 items...
WHY !
i have tested the sub with a object reference of my MDIForm . (by ref F as object,) -> so i check the num of columns and i have not 0 so with the event i am not in the actual MDIChild Form ?
I dont understand this..