Home All Groups Group Topic Archive Search About

treeview in windowsdialog

Author
23 May 2009 7:19 AM
Co
Hi All,

Is it possible to show my Treeview in a windowsdialog or folder
window?

Marco

Author
23 May 2009 9:06 AM
Cor Ligthert[MVP]
You can make your own dialog form.

It is simple a form that is called with showform
And for which the dispose method has to be called as it comes back, because
a dialog is used

Cor

Show quoteHide quote
"Co" <vonclausow***@gmail.com> wrote in message
news:07faa393-9848-4259-91f4-d572d02b159b@z9g2000yqi.googlegroups.com...
> Hi All,
>
> Is it possible to show my Treeview in a windowsdialog or folder
> window?
>
> Marco
Author
23 May 2009 9:35 AM
Co
Show quote Hide quote
On 23 mei, 11:06, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
wrote:
> You can make your own dialog form.
>
> It is simple a form that is called with showform
> And for which the dispose method has to be called as it comes back, because
> a dialog is used
>
> Cor
>
> "Co" <vonclausow***@gmail.com> wrote in message
>
> news:07faa393-9848-4259-91f4-d572d02b159b@z9g2000yqi.googlegroups.com...
>
> > Hi All,
>
> > Is it possible to show my Treeview in a windowsdialog or folder
> > window?
>
> > Marco

Cor,

I was already started creating such a form with a Treeview on it.
I call it as showDialog.
What do you mean witrh the Dispose.
Should the form be Disposed when it is closed???

Marco
Author
23 May 2009 9:54 AM
Cor Ligthert[MVP]
Marco,

\\
dim x as new formX
if x.ShowDialog = Dialog.OK then
    'Do your things
end if
x.Dispose
//
That text Dialog is probably something else I never know that from my head
because it comes with intelligence.

Cor

Show quoteHide quote
"Co" <vonclausow***@gmail.com> wrote in message
news:a76e3dee-6d4b-42f2-a387-124e1c6836db@s12g2000yqi.googlegroups.com...
> On 23 mei, 11:06, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
> wrote:
>> You can make your own dialog form.
>>
>> It is simple a form that is called with showform
>> And for which the dispose method has to be called as it comes back,
>> because
>> a dialog is used
>>
>> Cor
>>
>> "Co" <vonclausow***@gmail.com> wrote in message
>>
>> news:07faa393-9848-4259-91f4-d572d02b159b@z9g2000yqi.googlegroups.com...
>>
>> > Hi All,
>>
>> > Is it possible to show my Treeview in a windowsdialog or folder
>> > window?
>>
>> > Marco
>
> Cor,
>
> I was already started creating such a form with a Treeview on it.
> I call it as showDialog.
> What do you mean witrh the Dispose.
> Should the form be Disposed when it is closed???
>
> Marco
Author
24 May 2009 9:37 PM
Martin Horn
> x.Dispose

Is a dialog form not automatically garbage collected when it goes out of
scope then?

Martin

Show quoteHide quote
"Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl> wrote in message
news:OPSRPy42JHA.6004@TK2MSFTNGP02.phx.gbl...
> Marco,
>
> \\
> dim x as new formX
> if x.ShowDialog = Dialog.OK then
>    'Do your things
> end if
> x.Dispose
> //
> That text Dialog is probably something else I never know that from my head
> because it comes with intelligence.
>
> Cor
>
> "Co" <vonclausow***@gmail.com> wrote in message
> news:a76e3dee-6d4b-42f2-a387-124e1c6836db@s12g2000yqi.googlegroups.com...
>> On 23 mei, 11:06, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl>
>> wrote:
>>> You can make your own dialog form.
>>>
>>> It is simple a form that is called with showform
>>> And for which the dispose method has to be called as it comes back,
>>> because
>>> a dialog is used
>>>
>>> Cor
>>>
>>> "Co" <vonclausow***@gmail.com> wrote in message
>>>
>>> news:07faa393-9848-4259-91f4-d572d02b159b@z9g2000yqi.googlegroups.com...
>>>
>>> > Hi All,
>>>
>>> > Is it possible to show my Treeview in a windowsdialog or folder
>>> > window?
>>>
>>> > Marco
>>
>> Cor,
>>
>> I was already started creating such a form with a Treeview on it.
>> I call it as showDialog.
>> What do you mean witrh the Dispose.
>> Should the form be Disposed when it is closed???
>>
>> Marco
>
Author
24 May 2009 10:42 PM
Armin Zingler
Martin Horn wrote:
>> x.Dispose
>
> Is a dialog form not automatically garbage collected when it goes out
> of scope then?


Depends on what you mean with "go out of scope". Out of scope for the
application in the sense of the object not being accessible anymore? Or out
of scope in the sense of variables that are not accessible at the current
location? If it's the former, you are partially right, i.e. it can be
collected but it's not necessarily collected as soon as it is not accessible
anymore. That can happen later.

That was about garbage collection. It only collects/destroys _managed_
ressources. Disposing ressources is something different. It's an additional
pattern that enables us to release _unmanaged_ ressource before the GC
destroys the managed ressources that again release unmanaged ressources.

A Form's Dispose method is called automatically whenever the Form is closed
only if it's not a dialog Form (displayed using ShowDialog). This is because
you must have the chance to get the information from the controls (including
related unmanaged ressources) on the dialog Form. Therefore, you must
manually call Dispose afterwards.


Armin
Author
25 May 2009 2:44 AM
Cor Ligthert[MVP]
Armin,

Nice text, I assume that it is right that I use it in future?

Cor

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:u6UdGeM3JHA.5244@TK2MSFTNGP04.phx.gbl...
> Martin Horn wrote:
>>> x.Dispose
>>
>> Is a dialog form not automatically garbage collected when it goes out
>> of scope then?
>
>
> Depends on what you mean with "go out of scope". Out of scope for the
> application in the sense of the object not being accessible anymore? Or
> out
> of scope in the sense of variables that are not accessible at the current
> location? If it's the former, you are partially right, i.e. it can be
> collected but it's not necessarily collected as soon as it is not
> accessible
> anymore. That can happen later.
>
> That was about garbage collection. It only collects/destroys _managed_
> ressources. Disposing ressources is something different. It's an
> additional
> pattern that enables us to release _unmanaged_ ressource before the GC
> destroys the managed ressources that again release unmanaged ressources.
>
> A Form's Dispose method is called automatically whenever the Form is
> closed
> only if it's not a dialog Form (displayed using ShowDialog). This is
> because
> you must have the chance to get the information from the controls
> (including
> related unmanaged ressources) on the dialog Form. Therefore, you must
> manually call Dispose afterwards.
>
>
> Armin
>
Author
25 May 2009 11:00 AM
Armin Zingler
Cor Ligthert[MVP] wrote:
> Armin,
>
> Nice text, I assume that it is right that I use it in future?
>
> Cor

LOL    Do with it whatever you want and put your signature underneath. ;-)

(I was more expecting comments like this and that is not completeley
correct. (not in particular from you but in general))


Armin
Author
25 May 2009 11:26 AM
Martin Horn
So taking this scenario where 'Sub Test' is called multiple times do I need
to call dispose on the dialog to avoid wasting resources or will they be
freed automatically when needed?

Sub Test()
    dim d as frm = new dlgForm
    dlgForm.ShowDialog
    debug.print (dlgForm.SomeMethod)
End Sub

My understanding was that after the sub was exited the instance of the
dlgForm I created would be 'out of scope' and therefore eligable for garbage
collection. If this is wrong then I need to re-think my approach.

Martin.

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:u6UdGeM3JHA.5244@TK2MSFTNGP04.phx.gbl...
> Martin Horn wrote:
>>> x.Dispose
>>
>> Is a dialog form not automatically garbage collected when it goes out
>> of scope then?
>
>
> Depends on what you mean with "go out of scope". Out of scope for the
> application in the sense of the object not being accessible anymore? Or
> out
> of scope in the sense of variables that are not accessible at the current
> location? If it's the former, you are partially right, i.e. it can be
> collected but it's not necessarily collected as soon as it is not
> accessible
> anymore. That can happen later.
>
> That was about garbage collection. It only collects/destroys _managed_
> ressources. Disposing ressources is something different. It's an
> additional
> pattern that enables us to release _unmanaged_ ressource before the GC
> destroys the managed ressources that again release unmanaged ressources.
>
> A Form's Dispose method is called automatically whenever the Form is
> closed
> only if it's not a dialog Form (displayed using ShowDialog). This is
> because
> you must have the chance to get the information from the controls
> (including
> related unmanaged ressources) on the dialog Form. Therefore, you must
> manually call Dispose afterwards.
>
>
> Armin
>
Author
25 May 2009 11:28 AM
Martin Horn
Sorry this is how my example should have looked...

Sub Test()
    dim d as frm = new dlgForm
    d.ShowDialog
    debug.print (d.SomeMethod)
End Sub


Show quoteHide quote
"Martin Horn" <m***@nd.com> wrote in message
news:0gvSl.188217$i%2.81271@newsfe15.ams2...
> So taking this scenario where 'Sub Test' is called multiple times do I
> need to call dispose on the dialog to avoid wasting resources or will they
> be freed automatically when needed?
>
> Sub Test()
>    dim d as frm = new dlgForm
>    dlgForm.ShowDialog
>    debug.print (dlgForm.SomeMethod)
> End Sub
>
> My understanding was that after the sub was exited the instance of the
> dlgForm I created would be 'out of scope' and therefore eligable for
> garbage collection. If this is wrong then I need to re-think my approach.
>
> Martin.
>
> "Armin Zingler" <az.nospam@freenet.de> wrote in message
> news:u6UdGeM3JHA.5244@TK2MSFTNGP04.phx.gbl...
>> Martin Horn wrote:
>>>> x.Dispose
>>>
>>> Is a dialog form not automatically garbage collected when it goes out
>>> of scope then?
>>
>>
>> Depends on what you mean with "go out of scope". Out of scope for the
>> application in the sense of the object not being accessible anymore? Or
>> out
>> of scope in the sense of variables that are not accessible at the current
>> location? If it's the former, you are partially right, i.e. it can be
>> collected but it's not necessarily collected as soon as it is not
>> accessible
>> anymore. That can happen later.
>>
>> That was about garbage collection. It only collects/destroys _managed_
>> ressources. Disposing ressources is something different. It's an
>> additional
>> pattern that enables us to release _unmanaged_ ressource before the GC
>> destroys the managed ressources that again release unmanaged ressources.
>>
>> A Form's Dispose method is called automatically whenever the Form is
>> closed
>> only if it's not a dialog Form (displayed using ShowDialog). This is
>> because
>> you must have the chance to get the information from the controls
>> (including
>> related unmanaged ressources) on the dialog Form. Therefore, you must
>> manually call Dispose afterwards.
>>
>>
>> Armin
>>
>
>
Author
25 May 2009 3:53 PM
Armin Zingler
Martin Horn wrote:
Show quoteHide quote
> Sorry this is how my example should have looked...
>
> Sub Test()
>    dim d as frm = new dlgForm
>    d.ShowDialog
>    debug.print (d.SomeMethod)
> End Sub
>
>
> "Martin Horn" <m***@nd.com> wrote in message
> news:0gvSl.188217$i%2.81271@newsfe15.ams2...
>> So taking this scenario where 'Sub Test' is called multiple times do
>> I need to call dispose on the dialog to avoid wasting resources or
>> will they be freed automatically when needed?
>>
>> Sub Test()
>>    dim d as frm = new dlgForm
>>    dlgForm.ShowDialog
>>    debug.print (dlgForm.SomeMethod)
>> End Sub
>>
>> My understanding was that after the sub was exited the instance of
>> the dlgForm I created would be 'out of scope' and therefore eligable
>> for garbage collection. If this is wrong then I need to re-think my
>> approach.


Cor already wrote, though:
Yes, the variable dies as soon as the sub is left. As it held the only
reference to the Form, the GC _can_ collect the object (= the Form) from now
on, but  you don't know when it happens. Til then, all ressources (managed
and unmanaged) occupied by the Form are still reserved. As it is considered
good  programming style to release ressources ASAP, you can improve the
situation by bringing the release of the unmanaged ressources forward.
That's done by calling Dispose immediatelly after you don't need the Form
anymore.

Sub Test()
    dim d as new dlgForm
    d.ShowDialog
    debug.print (d.SomeMethod)
    d.Dispose
End Sub


Armin
Author
25 May 2009 8:42 PM
Martin Horn
Thanks Armin and Cor for making that clearer for me.

Martin.

Show quoteHide quote
"Armin Zingler" <az.nospam@freenet.de> wrote in message
news:eTziLSV3JHA.1712@TK2MSFTNGP03.phx.gbl...
> Martin Horn wrote:
>> Sorry this is how my example should have looked...
>>
>> Sub Test()
>>    dim d as frm = new dlgForm
>>    d.ShowDialog
>>    debug.print (d.SomeMethod)
>> End Sub
>>
>>
>> "Martin Horn" <m***@nd.com> wrote in message
>> news:0gvSl.188217$i%2.81271@newsfe15.ams2...
>>> So taking this scenario where 'Sub Test' is called multiple times do
>>> I need to call dispose on the dialog to avoid wasting resources or
>>> will they be freed automatically when needed?
>>>
>>> Sub Test()
>>>    dim d as frm = new dlgForm
>>>    dlgForm.ShowDialog
>>>    debug.print (dlgForm.SomeMethod)
>>> End Sub
>>>
>>> My understanding was that after the sub was exited the instance of
>>> the dlgForm I created would be 'out of scope' and therefore eligable
>>> for garbage collection. If this is wrong then I need to re-think my
>>> approach.
>
>
> Cor already wrote, though:
> Yes, the variable dies as soon as the sub is left. As it held the only
> reference to the Form, the GC _can_ collect the object (= the Form) from
> now
> on, but  you don't know when it happens. Til then, all ressources (managed
> and unmanaged) occupied by the Form are still reserved. As it is
> considered
> good  programming style to release ressources ASAP, you can improve the
> situation by bringing the release of the unmanaged ressources forward.
> That's done by calling Dispose immediatelly after you don't need the Form
> anymore.
>
> Sub Test()
>    dim d as new dlgForm
>    d.ShowDialog
>    debug.print (d.SomeMethod)
>    d.Dispose
> End Sub
>
>
> Armin
>
Author
25 May 2009 12:06 PM
Cor Ligthert[MVP]
Martin,

Armin wrote it so nice.

As extra: a ShowDialog form is nothing more then an old Dialog and therefore
it has unmanaged resources.

Before it goes out of scope it is clever to do  use its dispose method to
release the unmanaged resources.

That dispose method is implemented by the class where the Form derives from:
the component class.

Unmanaged resources have nothing to do with the managed objects.

A managed object can use (that becomes with all new thing every time less)
an unmanaged resource.

Therefore Yes it is wise to use the form.dispose  (unmanaged resources
method) as you have created that form new in your form and it will be go out
of scope.

Cor

Show quoteHide quote
"Martin Horn" <m***@nd.com> wrote in message
news:0gvSl.188217$i%2.81271@newsfe15.ams2...
> So taking this scenario where 'Sub Test' is called multiple times do I
> need to call dispose on the dialog to avoid wasting resources or will they
> be freed automatically when needed?
>
> Sub Test()
>    dim d as frm = new dlgForm
>    dlgForm.ShowDialog
>    debug.print (dlgForm.SomeMethod)
> End Sub
>
> My understanding was that after the sub was exited the instance of the
> dlgForm I created would be 'out of scope' and therefore eligable for
> garbage collection. If this is wrong then I need to re-think my approach.
>
> Martin.
>
> "Armin Zingler" <az.nospam@freenet.de> wrote in message
> news:u6UdGeM3JHA.5244@TK2MSFTNGP04.phx.gbl...
>> Martin Horn wrote:
>>>> x.Dispose
>>>
>>> Is a dialog form not automatically garbage collected when it goes out
>>> of scope then?
>>
>>
>> Depends on what you mean with "go out of scope". Out of scope for the
>> application in the sense of the object not being accessible anymore? Or
>> out
>> of scope in the sense of variables that are not accessible at the current
>> location? If it's the former, you are partially right, i.e. it can be
>> collected but it's not necessarily collected as soon as it is not
>> accessible
>> anymore. That can happen later.
>>
>> That was about garbage collection. It only collects/destroys _managed_
>> ressources. Disposing ressources is something different. It's an
>> additional
>> pattern that enables us to release _unmanaged_ ressource before the GC
>> destroys the managed ressources that again release unmanaged ressources.
>>
>> A Form's Dispose method is called automatically whenever the Form is
>> closed
>> only if it's not a dialog Form (displayed using ShowDialog). This is
>> because
>> you must have the chance to get the information from the controls
>> (including
>> related unmanaged ressources) on the dialog Form. Therefore, you must
>> manually call Dispose afterwards.
>>
>>
>> Armin
>>
>
>