Click here to Skip to main content
15,902,636 members
Home / Discussions / C#
   

C#

 
GeneralRe: Single instance of a form Pin
PHDENG8114-Dec-05 6:51
PHDENG8114-Dec-05 6:51 
GeneralRe: Single instance of a form Pin
Curtis Schlak.14-Dec-05 7:20
Curtis Schlak.14-Dec-05 7:20 
GeneralRe: Single instance of a form Pin
PHDENG8114-Dec-05 7:01
PHDENG8114-Dec-05 7:01 
GeneralRe: Single instance of a form Pin
Curtis Schlak.14-Dec-05 7:18
Curtis Schlak.14-Dec-05 7:18 
GeneralRe: Single instance of a form Pin
Curtis Schlak.14-Dec-05 7:25
Curtis Schlak.14-Dec-05 7:25 
GeneralRe: Single instance of a form Pin
PHDENG8114-Dec-05 8:16
PHDENG8114-Dec-05 8:16 
GeneralRe: Single instance of a form Pin
Curtis Schlak.14-Dec-05 10:40
Curtis Schlak.14-Dec-05 10:40 
GeneralRe: Single instance of a form Pin
PHDENG8119-Dec-05 2:27
PHDENG8119-Dec-05 2:27 
Curtis,

I am trying to control the number of instances of each form as well. So, working off of the previous code, I added this:

public static void LoadFormType(Type formType, Form parentForm, int instances)

{
lock( typeof( FormLoader ) )
{
if( eh == null )
{
eh = new EventHandler( FormClosed );
}
}
if( IsAlreadyLoaded( formType ) )
{
Form f = GetForm( formType );
f.Focus();
f.BringToFront();
return;
}

Form frm = (Form)Activator.CreateInstance(formType);
FlagAsLoaded( formType, frm, instances );//

DictionaryEntry[] myArr = new DictionaryEntry[m_InitializedForms.Count];//added
m_InitializedForms.CopyTo( myArr, 0 );//added

if(myArr[m_InitializedForms[formType.FullName]].Value <= instances)//added, clearly the cast types are wrong, but you get the idea
{
frm.Closed += eh;
frm.Show();
}
}

private static void FlagAsLoaded( Type formType, Form f, int instances )//
{
m_InitializedForms[formType.FullName] = f;
m_InitializedForms.Add(f, instances);//added

}

Then I would load a form as such:

FormLoader.LoadFormType(typeof(Form2), this, 1);

"1" indicating how many instances of the form should be allowed.

Thanks again for your help.



-- modified at 8:31 Monday 19th December, 2005
QuestionWrapper for BITS Pin
oddstar14-Dec-05 4:24
oddstar14-Dec-05 4:24 
AnswerRe: Wrapper for BITS Pin
WillemM14-Dec-05 9:27
WillemM14-Dec-05 9:27 
Questionwhich textbox is entered? Pin
melanieab14-Dec-05 4:04
melanieab14-Dec-05 4:04 
AnswerRe: which textbox is entered? Pin
J4amieC14-Dec-05 4:21
J4amieC14-Dec-05 4:21 
GeneralRe: which textbox is entered? Pin
melanieab14-Dec-05 5:03
melanieab14-Dec-05 5:03 
AnswerRe: which textbox is entered? Pin
anandss14-Dec-05 11:11
anandss14-Dec-05 11:11 
QuestionProblem in gridview(asp.net (C#)) Pin
montu337714-Dec-05 3:56
montu337714-Dec-05 3:56 
QuestionTopMost property c# win forms Pin
fady_sayegh14-Dec-05 3:37
fady_sayegh14-Dec-05 3:37 
AnswerRe: TopMost property c# win forms Pin
xtroll14-Dec-05 4:53
xtroll14-Dec-05 4:53 
QuestionCombobox Pin
SpeBeeTo14-Dec-05 2:57
SpeBeeTo14-Dec-05 2:57 
AnswerRe: Combobox Pin
albCode14-Dec-05 3:41
albCode14-Dec-05 3:41 
GeneralRe: Combobox Pin
SpeBeeTo14-Dec-05 3:46
SpeBeeTo14-Dec-05 3:46 
GeneralRe: Combobox Pin
albCode14-Dec-05 3:59
albCode14-Dec-05 3:59 
GeneralRe: Combobox Pin
SpeBeeTo14-Dec-05 6:36
SpeBeeTo14-Dec-05 6:36 
GeneralRe: Combobox Pin
tatchung14-Dec-05 19:01
tatchung14-Dec-05 19:01 
GeneralRe: Combobox Pin
albCode14-Dec-05 20:55
albCode14-Dec-05 20:55 
GeneralRe: Combobox Pin
SpeBeeTo15-Dec-05 1:28
SpeBeeTo15-Dec-05 1:28 

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.