gilad g Posted September 4, 2004 Posted September 4, 2004 My question actually regards Visual Studio 2005 Express. I have a form in my project - created by the desinger and all. It also has a memeber which implements IDisposable, and, because of that, needs to be disposed somehow. The problem is - where do i dispose it? A - ha! why not put the cleanup code in the designer's Dispose() method, you ask? Well, Microsoft chose to put the implementation of the designer aspect of Dispose() in the .Designer.cs. Since it's decalred there, i can't re-decalre it in my .cs file. I would very very much like to avoid editing the .desinger.cs file, for a few reasons: - Editing designer-generated code is usually a BAD idea. When you start messing with the designer's code, the designer can get seriously messed up. - I hate clicking the "show all files" button. I have to do this because the designer's file is hidden - all the reason why they are not "my" files, and I shouldn't touch them. Can anyone help me in accessing the Dispose() method, without messing with the .designer.cs file? Quote
Administrators PlausiblyDamp Posted September 4, 2004 Administrators Posted September 4, 2004 What kind of code would you be putting in your Dispose method? Would you not be able to put this code in either the FormClosed or FormClosing events as these will be called when the form is being destroyed. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Gurus* divil Posted September 6, 2004 *Gurus* Posted September 6, 2004 He should really still put the code in the Dispose method. Microsoft has chosen to put this method in the .designer file which is hidden in VB (in C# it will be visible, I'm told). However you're still free to edit this file and I don't think the Dispose method gets re-written by designers so your code should remain intact. Also you don't have to click "show all files" to get there - you can just right-click the call to InitializeComponent and choose Go to Definition to load the file. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
gilad g Posted September 10, 2004 Author Posted September 10, 2004 What kind of code would you be putting in your Dispose method? Would you not be able to put this code in either the FormClosed or FormClosing events as these will be called when the form is being destroyed. I actually thought of that. Putting this kind of code just doesn't feel right, since the events are fired when the form is closed, not disposed (I understand that there's a difference...) Quote
gilad g Posted September 10, 2004 Author Posted September 10, 2004 He should really still put the code in the Dispose method. Microsoft has chosen to put this method in the .designer file which is hidden in VB (in C# it will be visible' date=' I'm told). However you're still free to edit this file and I don't think the Dispose method gets re-written by designers so your code should remain intact.[/quote']Let me see if I get you - Basically, what you're saying is that there is no way to put my disposal code in the .cs file? Also you don't have to click "show all files" to get there - you can just right-click the call to InitializeComponent and choose Go to Definition to load the file.I prefer F12 :) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.