|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
treeview in windowsdialogHi All,
Is it possible to show my Treeview in a windowsdialog or folder window? Marco 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
Show quote
Hide quote
On 23 mei, 11:06, "Cor Ligthert[MVP]" <Notmyfirstn***@planet.nl> Cor,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 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 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 > 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 > Martin Horn wrote:
>> x.Dispose Depends on what you mean with "go out of scope". Out of scope for the> > Is a dialog form not automatically garbage collected when it goes out > of scope then? 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 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 > Cor Ligthert[MVP] wrote:
> Armin, LOL Do with it whatever you want and put your signature underneath. ;-)> > Nice text, I assume that it is right that I use it in future? > > Cor (I was more expecting comments like this and that is not completeley correct. (not in particular from you but in general)) Armin 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 > 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 >> > > Martin Horn wrote:
Show quoteHide quote > Sorry this is how my example should have looked... Cor already wrote, though:> > 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. 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 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 > 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 >> > >
Call button click event
Visual Studio 2008 and Classes Inheriting From System.Web.UI.WebControls.Style Problem with embedded carriage returns trouble reading word documents Good tutorial for working with XML Using function with PChar data type still problems reading word documents... how to know if to close sqlreader Build Number - how to auto increment? Question on system.mail.net and formatting mail body |
|||||||||||||||||||||||