And if you want to keep your code generic in your loop - as you have below -
I would create a base class - MySubForm (inherited from
System.Window.F orm) - add the MyUpdateSub procedure (or a function or
event - for this example it is a procedure) and inherit all your 'subforms'
from this class. That way you will ensure that all your sub-forms will have
a call to MyUpdateSub ... and you can still utilize your 'generic' control
loop from finding / displaying / updating the select treenode form...
So...
1. Create a new form in your project ... Call it something like
mySubFormBase
2. Add a PUBLIC OVERRIDABLE procedure / event ... MyUpdateSubFrom ... or
whatever ... MySubFormMakeVi sible
Public Overridable Sub MySubFormUpdate ()
End Sub
3. Save the form...
4. If you use namespaces ... add the mySubFormBase to your base namespace...
5. Now, BACKUP YOUR CURRENT FORMS ... make copies of them ...
6. For each of you sub forms ... open the <SubFormName>.d esigner.vb file...
7 REPLACE THE LINE:
INHERITS System.Windows. Forms.Form
with
INHERITS <yourProjectNam e>.MySubFormBas e
or
INHERITS <yourProjectNam e>.<yourNameSpa ce>.MySubFormBa se
where <yourProjectNam e = the name of your project
and
where yourNameSpace = the name of your namespace
8. Change your code in the your loop to ...
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is <myProjectName> .MySubFormBase Then
If ctl.Tag.ToStrin g = sTabKey.ToStrin g Then
ctl.BringToFron t()
ctl.Show()
ctl.MyUpdateSub Form() ' If Procedue ...
End If
End If
Next
9. In each subform code the following procedure...
Public Overrides Sub sMySubFormUpdat e()
MyBase.MySubFor mUpdate()
End Sub
This will work ...
now in all your subforms ... simply ...override the mySubFormUpdate
procedure with the appropriate code...
Public Class Form1
Public Overrides Sub MySubFormUpdate ()
MyBase.MySubFor mUpdate()
' Your code here ... update code
End Sub
End Class
If you take the approach and create a MySubFormUpdate procedure for each of
you sub forms, I am not sure how you would reference / call this from within
your Control Loop where ctl is a system.windows. form object ... Not sure how
you would 'dynamically' reference the procedure ?
JEff
<to************ **@uniroma1.itw rote in message
news:11******** **************@ p79g2000cwp.goo glegroups.com.. .
:)
of course it isn't. You are supposed to create it. Make sure it will be
visible outside the form
(public / friend ...).
Public Sub MyUpdateSub()
'...
'your update code
End Sub
-tom
Jerry ha scritto:
>I tryed that Tom,
it didn't work. The main form says MyUpdateSub is not a member of
system.windows .form.control. Can I change that?
Jerry
<to*********** ***@uniroma1.it schrieb im Newsbeitrag
news:11******* *************** @p79g2000cwp.go oglegroups.com. ..
Why not to use a form method:
ctl.BringToFron t()
ctl.Show()
ctl.MyUpdateSub (Args)
-tom
Jerry ha scritto:
Hi,
My app is controled by a treeview.
Each node brings a subform for input and calculations to the front.
The
subforms are loaded as controls on the main form.
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is Form Then
If ctl.Tag.ToStrin g = sTabKey.ToStrin g Then
ctl.BringToFron t()
ctl.Show()
End If
End If
Next
Which event can I use to fire my update sub on the subform when the
subform
is showen? I tryed gotfocus, but it didn't work.
Thanks,
Jerry