Click here to Skip to main content
16,006,348 members
Home / Discussions / C#
   

C#

 
GeneralRe: Handle without class Pin
eggie52-Jan-05 8:28
eggie52-Jan-05 8:28 
GeneralRe: Handle without class Pin
Stefan Troschuetz2-Jan-05 11:00
Stefan Troschuetz2-Jan-05 11:00 
GeneralC# Class Member Coding Practice Poll Pin
Rocky Moore1-Jan-05 21:33
Rocky Moore1-Jan-05 21:33 
GeneralListView Pin
Blue_Skye1-Jan-05 19:17
Blue_Skye1-Jan-05 19:17 
GeneralRe: ListView Pin
Adam Goossens1-Jan-05 19:21
Adam Goossens1-Jan-05 19:21 
GeneralStop Form Copies Pin
myNameIsRon1-Jan-05 12:20
myNameIsRon1-Jan-05 12:20 
GeneralRe: Stop Form Copies Pin
TyronX1-Jan-05 12:42
TyronX1-Jan-05 12:42 
GeneralRe: Stop Form Copies Pin
Adam Goossens1-Jan-05 19:18
Adam Goossens1-Jan-05 19:18 
Use the Singleton pattern. Create a static member variable in your form where you keep an instance of your form.

Add a static method to your form class called "GetInstance" (or whatever you like). In that method check to see if your static variable contains an instance of the form. If it doesn't, put one in there (using new).

Then return from GetInstance the form instance kept in your member variable.

This guarantees that as long as you always call "GetInstance" to get your form object (this will require discipline on your part) only one instance of a form will ever be created:

MyCustomForm myForm = MyCustomForm.GetInstance();
MyCustomForm myForm2 = MyCustomForm.GetInstance();

// myForm and myForm2 point to the same instance of MyCustomForm.

myForm.WindowState = Normal;
myForm.Activate();


This space for rent!
My Blog
QuestionTypecode of an Array? Pin
TyronX1-Jan-05 10:30
TyronX1-Jan-05 10:30 
AnswerRe: Typecode of an Array? Pin
TyronX1-Jan-05 10:37
TyronX1-Jan-05 10:37 
AnswerRe: Typecode of an Array? Pin
Adam Goossens1-Jan-05 15:07
Adam Goossens1-Jan-05 15:07 
AnswerRe: Typecode of an Array? Pin
leppie1-Jan-05 17:56
leppie1-Jan-05 17:56 
Questionusing windows media format & encoder API? Pin
Member 16179991-Jan-05 9:14
Member 16179991-Jan-05 9:14 
GeneralJoystick control again Pin
TyronX1-Jan-05 4:22
TyronX1-Jan-05 4:22 
GeneralRe: Joystick control again Pin
TyronX1-Jan-05 10:05
TyronX1-Jan-05 10:05 
GeneralXml Reading in .NET 2 Pin
thepersonof1-Jan-05 4:09
thepersonof1-Jan-05 4:09 
GeneralVisual Studio 2005 beta - an easy question Pin
McSam1-Jan-05 2:58
McSam1-Jan-05 2:58 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
Robert Rohde1-Jan-05 3:23
Robert Rohde1-Jan-05 3:23 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
McSam1-Jan-05 5:46
McSam1-Jan-05 5:46 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
Robert Rohde1-Jan-05 6:37
Robert Rohde1-Jan-05 6:37 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
Dennis C. Dietrich1-Jan-05 6:46
Dennis C. Dietrich1-Jan-05 6:46 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
McSam2-Jan-05 1:13
McSam2-Jan-05 1:13 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
Dennis C. Dietrich2-Jan-05 13:40
Dennis C. Dietrich2-Jan-05 13:40 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
McSam3-Jan-05 4:49
McSam3-Jan-05 4:49 
GeneralRe: Visual Studio 2005 beta - an easy question Pin
Dennis C. Dietrich3-Jan-05 7:58
Dennis C. Dietrich3-Jan-05 7:58 

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.