Click here to Skip to main content
15,900,511 members
Home / Discussions / C#
   

C#

 
Questionsearch dialog Pin
topksharma198210-Jul-07 2:59
topksharma198210-Jul-07 2:59 
AnswerRe: search dialog Pin
Luc Pattyn10-Jul-07 3:07
sitebuilderLuc Pattyn10-Jul-07 3:07 
GeneralRe: search dialog Pin
topksharma198210-Jul-07 4:07
topksharma198210-Jul-07 4:07 
GeneralRe: search dialog Pin
Luc Pattyn10-Jul-07 4:18
sitebuilderLuc Pattyn10-Jul-07 4:18 
GeneralRe: search dialog Pin
Luc Pattyn10-Jul-07 4:20
sitebuilderLuc Pattyn10-Jul-07 4:20 
AnswerRe: search dialog Pin
mav.northwind10-Jul-07 3:40
mav.northwind10-Jul-07 3:40 
QuestionHow to show a bookmarked position in default browser? Pin
mav.northwind10-Jul-07 2:18
mav.northwind10-Jul-07 2:18 
AnswerRe: How to show a bookmarked position in default browser? Pin
Luc Pattyn10-Jul-07 2:46
sitebuilderLuc Pattyn10-Jul-07 2:46 
GeneralRe: How to show a bookmarked position in default browser? Pin
mav.northwind10-Jul-07 3:34
mav.northwind10-Jul-07 3:34 
GeneralRe: How to show a bookmarked position in default browser? Pin
Luc Pattyn10-Jul-07 4:00
sitebuilderLuc Pattyn10-Jul-07 4:00 
GeneralRe: How to show a bookmarked position in default browser? Pin
mav.northwind10-Jul-07 4:24
mav.northwind10-Jul-07 4:24 
QuestionGeneric parameter/reflection problem Pin
Bekjong10-Jul-07 1:46
Bekjong10-Jul-07 1:46 
AnswerRe: Generic parameter/reflection problem Pin
Pete O'Hanlon10-Jul-07 1:59
mvePete O'Hanlon10-Jul-07 1:59 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 2:08
Bekjong10-Jul-07 2:08 
GeneralRe: Generic parameter/reflection problem Pin
Pete O'Hanlon10-Jul-07 2:32
mvePete O'Hanlon10-Jul-07 2:32 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 2:41
Bekjong10-Jul-07 2:41 
AnswerRe: Generic parameter/reflection problem Pin
Chintan.Desai10-Jul-07 2:08
Chintan.Desai10-Jul-07 2:08 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 2:22
Bekjong10-Jul-07 2:22 
GeneralRe: Generic parameter/reflection problem Pin
Le centriste10-Jul-07 2:38
Le centriste10-Jul-07 2:38 
AnswerRe: Generic parameter/reflection problem Pin
AFSEKI10-Jul-07 6:26
AFSEKI10-Jul-07 6:26 
GeneralRe: Generic parameter/reflection problem Pin
Bekjong10-Jul-07 22:05
Bekjong10-Jul-07 22:05 
AnswerRe: Generic parameter/reflection problem Pin
AFSEKI11-Jul-07 22:04
AFSEKI11-Jul-07 22:04 
No, you won't be creating a new Form each time. It was just an example,
you can replace:

pool.Add("myformid", new LoginForm());
pool.Add("myAboutformid", new AboutForm());

as

pool.Add("myformid", myAlreadyCreatedLoginForm);
pool.Add("myAboutformid", myAlreadyCreatedAboutForm());

also:

GetForm(...) code I sent you does not create anything. Do you see any "new" keyword in the code/or am I blind?

Result:

- You have an assembly created in you bin\debug folder in which your Forms are also embedded. This is your store to create the Forms at run-time. You want to store some configuration related to your forms, so what you need is to store this configuration like size and location somewhere like an xml file. If you've done it(you've written Some basic data(location, position) can be retrieved from a file), then you want to get a Form from the pool. Then your pool is the one which is responsible of returning an instance of the Form type if there is already one, created in pre-call to GetForm(...) or you want to create a new instance with the configuration parameters stored using reflection. If this is what you want:

// The configurtation of the Form you serialize/deserialize
public class FormConfig : ConfigurationProperty /*or string, or xml file, or whatever you want */
{
}

public T GetForm<t>(string form_id) where T: Form
{
if(pool.ContainsKey(form_id))
{
return pool[form_id] as T;
}
else
{
// you may have a look at other overloaded method(s) of Activator.CreateInstance
return Activator.CreateInstance(T, new object[]{GetConfig(typeof(mySerializedForm))}) as T;
}
}

public FormConfig GetConfig(string key)
{
return ..... // return the deserialized config
}
public FormConfig GetConfig(Type key)
{
return ..... // return the deserialized config
}

"Peace at home, peace in the world"
Mustafa Kemal Atatürk(the founder of the Republic of Turkey and its first President.))
GeneralRe: Generic parameter/reflection problem Pin
Bekjong11-Jul-07 22:38
Bekjong11-Jul-07 22:38 
AnswerRe: Generic parameter/reflection problem Pin
AFSEKI11-Jul-07 23:58
AFSEKI11-Jul-07 23:58 
QuestionOPC communication in C# Pin
k reddy10-Jul-07 1:38
k reddy10-Jul-07 1:38 

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.