Home All Groups Group Topic Archive Search About
Author
1 Aug 2006 9:35 AM
Jerry
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.ToString = sTabKey.ToString Then

                    ctl.BringToFront()
                    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

Author
1 Aug 2006 9:55 AM
tommaso.gastaldi
Why not to use a form method:

                    ctl.BringToFront()
                    ctl.Show()
                    ctl.MyUpdateSub(Args)

-tom

Jerry ha scritto:

Show quoteHide quote
> 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.ToString = sTabKey.ToString Then
>
>                     ctl.BringToFront()
>                     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
Author
1 Aug 2006 10:16 AM
Jerry
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


<tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
Show quoteHide quote
news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
> Why not to use a form method:
>
>                    ctl.BringToFront()
>                    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.ToString = sTabKey.ToString Then
>>
>>                     ctl.BringToFront()
>>                     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
>
Author
1 Aug 2006 10:57 AM
tommaso.gastaldi
:)
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:

Show quoteHide quote
> 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
>
>
> <tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
> news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
> > Why not to use a form method:
> >
> >                    ctl.BringToFront()
> >                    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.ToString = sTabKey.ToString Then
> >>
> >>                     ctl.BringToFront()
> >>                     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
> >
Author
1 Aug 2006 12:50 PM
jeff
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.Form) - 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 ... MySubFormMakeVisible
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>.designer.vb file...

7 REPLACE THE LINE:

INHERITS System.Windows.Forms.Form

with

INHERITS <yourProjectName>.MySubFormBase
or
INHERITS <yourProjectName>.<yourNameSpace>.MySubFormBase

where <yourProjectName = 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.ToString = sTabKey.ToString Then
            ctl.BringToFront()
            ctl.Show()
            ctl.MyUpdateSubForm() ' If Procedue ...
        End If
    End If
Next

9. In each subform code the following procedure...

Public Overrides Sub sMySubFormUpdate()

    MyBase.MySubFormUpdate()

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.MySubFormUpdate()

            ' 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


<tommaso.gasta***@uniroma1.it> wrote in message
Show quoteHide quote
news:1154429860.896894.179210@p79g2000cwp.googlegroups.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
>>
>>
>> <tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
>> news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
>> > Why not to use a form method:
>> >
>> >                    ctl.BringToFront()
>> >                    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.ToString = sTabKey.ToString Then
>> >>
>> >>                     ctl.BringToFront()
>> >>                     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
>> >
>
Author
1 Aug 2006 9:08 PM
Jerry
Thanks Tom,
but I had tried that too. Didn't work....

Jeff, this looks nice. I'll try this first thing tomorrow. Thanks for your
effort and yours too Tom.

Jerry



Show quoteHide quote
"jeff" <jhersey at allnorth dottt com> schrieb im Newsbeitrag
news:epwxVkWtGHA.1504@TK2MSFTNGP03.phx.gbl...
>
> 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.Form) - 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 ... MySubFormMakeVisible
> 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>.designer.vb
> file...
>
> 7 REPLACE THE LINE:
>
> INHERITS System.Windows.Forms.Form
>
> with
>
> INHERITS <yourProjectName>.MySubFormBase
> or
> INHERITS <yourProjectName>.<yourNameSpace>.MySubFormBase
>
> where <yourProjectName = 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.ToString = sTabKey.ToString Then
>            ctl.BringToFront()
>            ctl.Show()
>            ctl.MyUpdateSubForm() ' If Procedue ...
>        End If
>    End If
> Next
>
> 9. In each subform code the following procedure...
>
> Public Overrides Sub sMySubFormUpdate()
>
>    MyBase.MySubFormUpdate()
>
> 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.MySubFormUpdate()
>
>            ' 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
>
>
> <tommaso.gasta***@uniroma1.it> wrote in message
> news:1154429860.896894.179210@p79g2000cwp.googlegroups.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
>>>
>>>
>>> <tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
>>> news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
>>> > Why not to use a form method:
>>> >
>>> >                    ctl.BringToFront()
>>> >                    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.ToString = sTabKey.ToString Then
>>> >>
>>> >>                     ctl.BringToFront()
>>> >>                     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
>>> >
>>
>
>
Author
1 Aug 2006 9:13 PM
Jerry
Jeff,

just got through reading the rest. Your right, how am I going to reference
the others. This looks very good.

Thanks,

Jerry


Show quoteHide quote
"Jerry" <jerry***@gmx.net> schrieb im Newsbeitrag
news:eaofsd$6pq$02$1@news.t-online.com...
> Thanks Tom,
> but I had tried that too. Didn't work....
>
> Jeff, this looks nice. I'll try this first thing tomorrow. Thanks for your
> effort and yours too Tom.
>
> Jerry
>
>
>
> "jeff" <jhersey at allnorth dottt com> schrieb im Newsbeitrag
> news:epwxVkWtGHA.1504@TK2MSFTNGP03.phx.gbl...
>>
>> 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.Form) - 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 ... MySubFormMakeVisible
>> 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>.designer.vb
>> file...
>>
>> 7 REPLACE THE LINE:
>>
>> INHERITS System.Windows.Forms.Form
>>
>> with
>>
>> INHERITS <yourProjectName>.MySubFormBase
>> or
>> INHERITS <yourProjectName>.<yourNameSpace>.MySubFormBase
>>
>> where <yourProjectName = 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.ToString = sTabKey.ToString Then
>>            ctl.BringToFront()
>>            ctl.Show()
>>            ctl.MyUpdateSubForm() ' If Procedue ...
>>        End If
>>    End If
>> Next
>>
>> 9. In each subform code the following procedure...
>>
>> Public Overrides Sub sMySubFormUpdate()
>>
>>    MyBase.MySubFormUpdate()
>>
>> 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.MySubFormUpdate()
>>
>>            ' 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
>>
>>
>> <tommaso.gasta***@uniroma1.it> wrote in message
>> news:1154429860.896894.179210@p79g2000cwp.googlegroups.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
>>>>
>>>>
>>>> <tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
>>>> news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
>>>> > Why not to use a form method:
>>>> >
>>>> >                    ctl.BringToFront()
>>>> >                    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.ToString = sTabKey.ToString Then
>>>> >>
>>>> >>                     ctl.BringToFront()
>>>> >>                     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
>>>> >
>>>
>>
>>
>
>
Author
1 Aug 2006 10:36 PM
jeff
The others?  Other sub forms ... as I mentioned, you will need to change all
the subform parent class inorder for this work ... you can not selectively
choose to do it for some forms and not others that you want to control with
your treeview...otherwise you will need to change your control's loop ...

the 'ctl's that you loop through must be from the same 'base' class ...
create a base class form, add your 'overridable' procedure, and when you
iterate through the controls on a 'master' window looking for the 'subforms'
check for the following...

If TypeOf ctl Is <myProjectName>.MySubFormBase Then


Instead of ...

If TypeOf ctl Is System.Windows.Form Then

This will ensure...

a. you have a subform that has your procedure
b. generically code against your procedure.

Jeff.



Show quoteHide quote
"Jerry" <jerry***@gmx.net> wrote in message
news:eaog5m$aib$03$1@news.t-online.com...
> Jeff,
>
> just got through reading the rest. Your right, how am I going to reference
> the others. This looks very good.
>
> Thanks,
>
> Jerry
>
>
> "Jerry" <jerry***@gmx.net> schrieb im Newsbeitrag
> news:eaofsd$6pq$02$1@news.t-online.com...
>> Thanks Tom,
>> but I had tried that too. Didn't work....
>>
>> Jeff, this looks nice. I'll try this first thing tomorrow. Thanks for
>> your effort and yours too Tom.
>>
>> Jerry
>>
>>
>>
>> "jeff" <jhersey at allnorth dottt com> schrieb im Newsbeitrag
>> news:epwxVkWtGHA.1504@TK2MSFTNGP03.phx.gbl...
>>>
>>> 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.Form) - 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 ... MySubFormMakeVisible
>>> 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>.designer.vb
>>> file...
>>>
>>> 7 REPLACE THE LINE:
>>>
>>> INHERITS System.Windows.Forms.Form
>>>
>>> with
>>>
>>> INHERITS <yourProjectName>.MySubFormBase
>>> or
>>> INHERITS <yourProjectName>.<yourNameSpace>.MySubFormBase
>>>
>>> where <yourProjectName = 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.ToString = sTabKey.ToString Then
>>>            ctl.BringToFront()
>>>            ctl.Show()
>>>            ctl.MyUpdateSubForm() ' If Procedue ...
>>>        End If
>>>    End If
>>> Next
>>>
>>> 9. In each subform code the following procedure...
>>>
>>> Public Overrides Sub sMySubFormUpdate()
>>>
>>>    MyBase.MySubFormUpdate()
>>>
>>> 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.MySubFormUpdate()
>>>
>>>            ' 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
>>>
>>>
>>> <tommaso.gasta***@uniroma1.it> wrote in message
>>> news:1154429860.896894.179210@p79g2000cwp.googlegroups.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
>>>>>
>>>>>
>>>>> <tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
>>>>> news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
>>>>> > Why not to use a form method:
>>>>> >
>>>>> >                    ctl.BringToFront()
>>>>> >                    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.ToString = sTabKey.ToString Then
>>>>> >>
>>>>> >>                     ctl.BringToFront()
>>>>> >>                     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
>>>>> >
>>>>
>>>
>>>
>>
>>
>
>
Author
2 Aug 2006 11:18 AM
jeff
For example ...

If you have two or more 'types' of these subforms ... you need to code
accordingly...

Instead of having a If TypeOf ... change it to ...

Select Case TypeOf Ctl

    Case System.Windows.Form

    Case <myProject>.MySubFormBase

    Case ...

End Select

Since VB only knows that the procedure exists for the BaseSubForm's ... you
can only call it from the appropriate case ...

So, if you have 'seven' sub forms but only 3 need to use the update
procedure, than only those three need to inherit from you base class -
MySubFormBase ...

However, I would recommend 'inheriting' all you subforms from the same base
class form ... that way you will always have this functionality available.

IMHO, it is good practice to always inherit ALL your forms from a custom
base class .... even if in the beginning u do not intend on extending it ...
this will allow you to easily extend all your forms to include this type of
functionality ...

Jeff


Show quoteHide quote
"jeff" <jhersey at allnorth dottt com> wrote in message
news:%23qHCfrbtGHA.3552@TK2MSFTNGP03.phx.gbl...
>
> The others?  Other sub forms ... as I mentioned, you will need to change
> all the subform parent class inorder for this work ... you can not
> selectively choose to do it for some forms and not others that you want to
> control with your treeview...otherwise you will need to change your
> control's loop ...
>
> the 'ctl's that you loop through must be from the same 'base' class ...
> create a base class form, add your 'overridable' procedure, and when you
> iterate through the controls on a 'master' window looking for the
> 'subforms' check for the following...
>
> If TypeOf ctl Is <myProjectName>.MySubFormBase Then
>
>
> Instead of ...
>
> If TypeOf ctl Is System.Windows.Form Then
>
> This will ensure...
>
> a. you have a subform that has your procedure
> b. generically code against your procedure.
>
> Jeff.
>
>
>
> "Jerry" <jerry***@gmx.net> wrote in message
> news:eaog5m$aib$03$1@news.t-online.com...
>> Jeff,
>>
>> just got through reading the rest. Your right, how am I going to
>> reference the others. This looks very good.
>>
>> Thanks,
>>
>> Jerry
>>
>>
>> "Jerry" <jerry***@gmx.net> schrieb im Newsbeitrag
>> news:eaofsd$6pq$02$1@news.t-online.com...
>>> Thanks Tom,
>>> but I had tried that too. Didn't work....
>>>
>>> Jeff, this looks nice. I'll try this first thing tomorrow. Thanks for
>>> your effort and yours too Tom.
>>>
>>> Jerry
>>>
>>>
>>>
>>> "jeff" <jhersey at allnorth dottt com> schrieb im Newsbeitrag
>>> news:epwxVkWtGHA.1504@TK2MSFTNGP03.phx.gbl...
>>>>
>>>> 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.Form) - 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 ... MySubFormMakeVisible
>>>> 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>.designer.vb
>>>> file...
>>>>
>>>> 7 REPLACE THE LINE:
>>>>
>>>> INHERITS System.Windows.Forms.Form
>>>>
>>>> with
>>>>
>>>> INHERITS <yourProjectName>.MySubFormBase
>>>> or
>>>> INHERITS <yourProjectName>.<yourNameSpace>.MySubFormBase
>>>>
>>>> where <yourProjectName = 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.ToString = sTabKey.ToString Then
>>>>            ctl.BringToFront()
>>>>            ctl.Show()
>>>>            ctl.MyUpdateSubForm() ' If Procedue ...
>>>>        End If
>>>>    End If
>>>> Next
>>>>
>>>> 9. In each subform code the following procedure...
>>>>
>>>> Public Overrides Sub sMySubFormUpdate()
>>>>
>>>>    MyBase.MySubFormUpdate()
>>>>
>>>> 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.MySubFormUpdate()
>>>>
>>>>            ' 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
>>>>
>>>>
>>>> <tommaso.gasta***@uniroma1.it> wrote in message
>>>> news:1154429860.896894.179210@p79g2000cwp.googlegroups.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
>>>>>>
>>>>>>
>>>>>> <tommaso.gasta***@uniroma1.it> schrieb im Newsbeitrag
>>>>>> news:1154426154.664513.208260@p79g2000cwp.googlegroups.com...
>>>>>> > Why not to use a form method:
>>>>>> >
>>>>>> >                    ctl.BringToFront()
>>>>>> >                    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.ToString = sTabKey.ToString Then
>>>>>> >>
>>>>>> >>                     ctl.BringToFront()
>>>>>> >>                     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
>>>>>> >
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>