JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
So i've got several SplitContainer's on the form, and they all have their event set to a method: SplitterMoved() for purposes of saving the current layout of the form.
my method:
the bolded line is import later. So I open my app, which initially displays the Login Form, which if successful, opens my MainForm.
The Mainform is crazily enough, the Main Application Form, from which i open other forms, specifically the AdminForm. Now when I close the AdminForm it doesn't specifically close it if the reason is for a userclosing, (ie via, menu, Form.Close(), or the X button on the form), it only hides it in those circumstance so that I can reload it quicky by simply listening to the VisibleChanged() event. This works fine.
here is the pattern for my error:
Now, basically it seems, that if in my mainform.closing method if I put in an AdminForm.Close() the error is abated. So once again the stupidity of a langauge design trying to think for the programmer has screwed everything up, because I can't help but wonder how can an event fire when the object that created it is being disposed? The Form is going bye-bye and yet i'm getting an event fired after-the-fact. Even the Disposing property says the address for the method is null so that doesn't work either. How can i prevent, no matter what, the event's from triggering when the form is being closed on the VB application side of things?
Thanks
my method:
VB.NET:
Private Sub SplitContainer_SplitterMoved(ByVal sender As Object, ByVal e As System.Windows.Forms.SplitterEventArgs) _
Handles SplitterH_Tab1.SplitterMoved, SplitterV_Tables.SplitterMoved, SplitterH_Childs.SplitterMoved
If (Not _Refreshing) AndAlso (_RexCon IsNot Nothing) AndAlso (Not Me.Disposing) Then
Dim sc As SplitContainer = DirectCast(sender, SplitContainer)
Dim layoutKey As String = Strings.Right(_RexCon.ActiveTable, _RexCon.ActiveTable.Length - 4)
Console.WriteLine("SplitterMoved - " & sc.Name & ": " & e.SplitX & "x" & e.SplitY)
If layoutKey.IsValid AndAlso _layout.HasKey(layoutKey) Then
[B] _layout(nav_TablesCmb.Text)(sc.Name).GetCurrentValues()[/B]
End If
End If
End Sub
The Mainform is crazily enough, the Main Application Form, from which i open other forms, specifically the AdminForm. Now when I close the AdminForm it doesn't specifically close it if the reason is for a userclosing, (ie via, menu, Form.Close(), or the X button on the form), it only hides it in those circumstance so that I can reload it quicky by simply listening to the VisibleChanged() event. This works fine.
here is the pattern for my error:
- Mainform Open
- Open AdminForm
- Close AdminForm
- Close MainForm (no Error)
- MainForm Open
- Open MainForm
- Close MainForm
- Halt on Error at Bolded Line : Object Cannot be Null
Now, basically it seems, that if in my mainform.closing method if I put in an AdminForm.Close() the error is abated. So once again the stupidity of a langauge design trying to think for the programmer has screwed everything up, because I can't help but wonder how can an event fire when the object that created it is being disposed? The Form is going bye-bye and yet i'm getting an event fired after-the-fact. Even the Disposing property says the address for the method is null so that doesn't work either. How can i prevent, no matter what, the event's from triggering when the form is being closed on the VB application side of things?
Thanks