Hi guys, i'm wondering if anyone knows any other better way of doing this.. here's what i have.
Mainform - with a toolbar, each toolbar function is based on the currentactive MDIchild form.
Here's my current code for the clicking toolbar event.
As you can see i only have 4 childs with 3 toolbar buttons defined... if i have 12 toolbar buttons with 50 childforms.. i'll have.. 12x50 lines of stuff to write.. which isn't pretty..
is there a general way i can check which mdiactivechild is currently selected so i can call the functions properly?
Mainform - with a toolbar, each toolbar function is based on the currentactive MDIchild form.
Here's my current code for the clicking toolbar event.
VB.NET:
Private Sub tlbMainMenu_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tlbMainMenu.ButtonClick
Select Case tlbMainMenu.Buttons.IndexOf(e.Button)
Case intcTB_ORG_ORDER 'Display records in original order
If TypeOf Me.ActiveMdiChild Is Child1Then
DirectCast(Me.ActiveMdiChild, Child1).SortRecords()
ElseIf TypeOf Me.ActiveMdiChild Is Child2 Then
DirectCast(Me.ActiveMdiChild, Child2).SortRecords()
ElseIf TypeOf Me.ActiveMdiChild Is Child3 Then
DirectCast(Me.ActiveMdiChild, Child3).SortRecords()
ElseIf TypeOf Me.ActiveMdiChild Is Child4 Then
DirectCast(Me.ActiveMdiChild, Child4).SortRecords()
Case intcTB_REPORT
If TypeOf Me.ActiveMdiChild Is Child1Then
DirectCast(Me.ActiveMdiChild, Child1).REPORT()
ElseIf TypeOf Me.ActiveMdiChild Is Child2 Then
DirectCast(Me.ActiveMdiChild, Child2).REPORT()
ElseIf TypeOf Me.ActiveMdiChild Is Child3 Then
DirectCast(Me.ActiveMdiChild, Child3).REPORT()
ElseIf TypeOf Me.ActiveMdiChild Is Child4 Then
DirectCast(Me.ActiveMdiChild, Child4).REPORT()
Case intcTB_SAVE
If TypeOf Me.ActiveMdiChild Is Child1Then
DirectCast(Me.ActiveMdiChild, Child1).SAVE()
ElseIf TypeOf Me.ActiveMdiChild Is Child2 Then
DirectCast(Me.ActiveMdiChild, Child2).SAVE()
ElseIf TypeOf Me.ActiveMdiChild Is Child3 Then
DirectCast(Me.ActiveMdiChild, Child3).SAVE()
ElseIf TypeOf Me.ActiveMdiChild Is Child4 Then
DirectCast(Me.ActiveMdiChild, Child4).SAVE()
End Select
'Code on child1,Child2,child3,child4 forms
SortRecords
Report
Save
all 3 functions are different on each childform
As you can see i only have 4 childs with 3 toolbar buttons defined... if i have 12 toolbar buttons with 50 childforms.. i'll have.. 12x50 lines of stuff to write.. which isn't pretty..
is there a general way i can check which mdiactivechild is currently selected so i can call the functions properly?