Click here to Skip to main content
15,923,789 members
Home / Discussions / C#
   

C#

 
AnswerRe: mySQLDriverCS help Pin
Colin Angus Mackay30-Aug-05 20:25
Colin Angus Mackay30-Aug-05 20:25 
GeneralRe: mySQLDriverCS help Pin
binglin30-Aug-05 21:03
binglin30-Aug-05 21:03 
Questionhow can i update to access db?? Pin
nidhelp30-Aug-05 18:58
nidhelp30-Aug-05 18:58 
AnswerRe: how can i update to access db?? Pin
Guffa30-Aug-05 21:01
Guffa30-Aug-05 21:01 
GeneralRe: how can i update to access db?? Pin
nidhelp30-Aug-05 22:14
nidhelp30-Aug-05 22:14 
GeneralRe: how can i update to access db?? Pin
nidhelp30-Aug-05 22:53
nidhelp30-Aug-05 22:53 
AnswerRe: how can i update to access db?? Pin
mostafa_h31-Aug-05 2:39
mostafa_h31-Aug-05 2:39 
QuestionWindows Forms: how to do automatic disposing? Here is my answer... Pin
sgatto15930-Aug-05 17:07
sgatto15930-Aug-05 17:07 
Hi all,

here's a question for you.

What if one needs to do automatic disposing of a form's components when it is closed ?
And what if one wan't write Dispose() for each component ?

Here is my answer, I hope you agree is correct. I tested it in win2k/winXp with taskmanager and I have seen this piece of code effectively release the memory when the form is closed.

Suggestions are really appreciated.

/*
 Here f is the Form. This method is to be called in the Dispose method of the subclass of your Form.
*/
public static void disposeComponents(Component f) {
   foreach (FieldInfo fieldInfo in f.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic)) {
      object value = fieldInfo.GetValue(f);
      if(value is Component) {
         ((Component)value).Dispose();
         fieldInfo.SetValue(f, null);
      }
   }
   System.GC.Collect();
}

AnswerRe: Windows Forms: how to do automatic disposing? Here is my answer... Pin
Christian Graus30-Aug-05 17:15
protectorChristian Graus30-Aug-05 17:15 
GeneralRe: Windows Forms: how to do automatic disposing? Here is my answer... Pin
sgatto15930-Aug-05 17:55
sgatto15930-Aug-05 17:55 
AnswerRe: Windows Forms: how to do automatic disposing? Here is my answer... Pin
sgatto15930-Aug-05 17:52
sgatto15930-Aug-05 17:52 
GeneralRe: Windows Forms: how to do automatic disposing? Here is my answer... Pin
Christian Graus30-Aug-05 18:16
protectorChristian Graus30-Aug-05 18:16 
GeneralRe: Windows Forms: how to do automatic disposing? Here is my answer... Pin
sgatto15930-Aug-05 20:21
sgatto15930-Aug-05 20:21 
QuestionC# .exe icon Pin
kenexcelon30-Aug-05 15:52
kenexcelon30-Aug-05 15:52 
AnswerRe: C# .exe icon Pin
Anonymous30-Aug-05 17:31
Anonymous30-Aug-05 17:31 
AnswerRe: C# .exe icon Pin
kenexcelon30-Aug-05 18:59
kenexcelon30-Aug-05 18:59 
AnswerRe: C# .exe icon Pin
leppie30-Aug-05 21:53
leppie30-Aug-05 21:53 
GeneralRe: C# .exe icon Pin
kenexcelon31-Aug-05 4:34
kenexcelon31-Aug-05 4:34 
Questionjump start on Regex validation Pin
...---...30-Aug-05 15:20
...---...30-Aug-05 15:20 
AnswerRe: jump start on Regex validation Pin
Christian Graus30-Aug-05 15:41
protectorChristian Graus30-Aug-05 15:41 
GeneralRe: jump start on Regex validation Pin
Susan Hernandez31-Aug-05 14:39
Susan Hernandez31-Aug-05 14:39 
QuestionWord Object C# Pin
mitsemaj30-Aug-05 14:58
mitsemaj30-Aug-05 14:58 
AnswerRe: Word Object C# Pin
mitsemaj30-Aug-05 21:43
mitsemaj30-Aug-05 21:43 
QuestionWord Object Pin
mitsemaj30-Aug-05 14:56
mitsemaj30-Aug-05 14:56 
QuestionClass question Pin
kenexcelon30-Aug-05 13:51
kenexcelon30-Aug-05 13:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.