473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Dynamically Form Property Setting (Urgent)

Hi all;

I have one application in which I read form names from database to be opened.
I open form with the code below, and call its show method for form to be shown

but before this, I must set MdiChild property to true to make this form child

I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/

public void OpenForm(string pi_form_dll_name)

{

bool bFindForm = false; Assembly formAsm = null;

try

{

this.Cursor = Cursors.WaitCursor;

formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");

Type[] ClassTypes = formAsm.GetTypes();

foreach(Type clsType in ClassTypes)

{

if (clsType.IsSubclassOf(typeof(Form)))

{

object o = System.Activator.CreateInstance(clsType);

MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke property of MdpParent=this instead of invoking method ?

mi.Invoke(o, null); bFindForm = true; break;

}

}
if (bFindForm == false)

{

string sErr = pi_form_dll_name + ".dll does not have " +

"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);

}

}

catch(System.Exception eSysExc)

{

MessageBox.Show(eSysExc.Message,"Form Open Error");

}

finally

{

this.Cursor = Cursors.Arrow;

}

}

/*------------------------------------------------------------------------*/


helps'll be appreciated..
Ahmet
Nov 15 '05 #1
4 1830
Ahmet

Why don't you cast the object 'o' to Form and work from it that rather than
trying to do everything via reflection on object?

Regards
Lee

"Ahmet" <ak*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi all;

I have one application in which I read form names from database to be
opened.
I open form with the code below, and call its show method for form to be
shown

but before this, I must set MdiChild property to true to make this form
child

I can call functions as you can see like (show), how can i set.MdiParent =
this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/
public void OpenForm(string pi_form_dll_name)
{
bool bFindForm = false; Assembly formAsm = null;
try
{
this.Cursor = Cursors.WaitCursor;
formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");
Type[] ClassTypes = formAsm.GetTypes();
foreach(Type clsType in ClassTypes)
{
if (clsType.IsSubclassOf(typeof(Form)))
{
object o = System.Activator.CreateInstance(clsType);
MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke
property of MdpParent=this instead of invoking method ?
mi.Invoke(o, null); bFindForm = true; break;
}
}
if (bFindForm == false)
{
string sErr = pi_form_dll_name + ".dll does not have " +
"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);
}
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message,"Form Open Error");
}
finally
{
this.Cursor = Cursors.Arrow;
}
}
/*------------------------------------------------------------------------*/

helps'll be appreciated..
Ahmet
Nov 15 '05 #2

Sorry, misunderstood,
can please give an example about what you are saying ?
"Lee Alexander" <lee@No_Spam_Please_Digita.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Ahmet

Why don't you cast the object 'o' to Form and work from it that rather than trying to do everything via reflection on object?

Regards
Lee

"Ahmet" <ak*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi all;

I have one application in which I read form names from database to be
opened.
I open form with the code below, and call its show method for form to be
shown

but before this, I must set MdiChild property to true to make this form
child

I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/ public void OpenForm(string pi_form_dll_name)
{
bool bFindForm = false; Assembly formAsm = null;
try
{
this.Cursor = Cursors.WaitCursor;
formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");
Type[] ClassTypes = formAsm.GetTypes();
foreach(Type clsType in ClassTypes)
{
if (clsType.IsSubclassOf(typeof(Form)))
{
object o = System.Activator.CreateInstance(clsType);
MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke
property of MdpParent=this instead of invoking method ?
mi.Invoke(o, null); bFindForm = true; break;
}
}
if (bFindForm == false)
{
string sErr = pi_form_dll_name + ".dll does not have " +
"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);
}
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message,"Form Open Error");
}
finally
{
this.Cursor = Cursors.Arrow;
}
}
/*------------------------------------------------------------------------*/
helps'll be appreciated..
Ahmet

Nov 15 '05 #3

Because I read form's dll name from database and I find dll for this form
then dynamically load this form.

I dont want to make

if (dbObj.FormName = "Customer")
fCustomer.Open();
else
else
....
because I have 100 + forms
I call Show Method to show but it must be MdiChild, so I must set MDiParent
of any opening form to this pointer


"Lee Alexander" <lee@No_Spam_Please_Digita.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Ahmet

Why don't you cast the object 'o' to Form and work from it that rather than trying to do everything via reflection on object?

Regards
Lee

"Ahmet" <ak*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi all;

I have one application in which I read form names from database to be
opened.
I open form with the code below, and call its show method for form to be
shown

but before this, I must set MdiChild property to true to make this form
child

I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/ public void OpenForm(string pi_form_dll_name)
{
bool bFindForm = false; Assembly formAsm = null;
try
{
this.Cursor = Cursors.WaitCursor;
formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");
Type[] ClassTypes = formAsm.GetTypes();
foreach(Type clsType in ClassTypes)
{
if (clsType.IsSubclassOf(typeof(Form)))
{
object o = System.Activator.CreateInstance(clsType);
MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke
property of MdpParent=this instead of invoking method ?
mi.Invoke(o, null); bFindForm = true; break;
}
}
if (bFindForm == false)
{
string sErr = pi_form_dll_name + ".dll does not have " +
"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);
}
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message,"Form Open Error");
}
finally
{
this.Cursor = Cursors.Arrow;
}
}
/*------------------------------------------------------------------------*/
helps'll be appreciated..
Ahmet

Nov 15 '05 #4

Thanks.
it worked..
"Lee Alexander" <lee@No_Spam_Please_Digita.com> wrote in message
news:ej**************@TK2MSFTNGP09.phx.gbl...
Ahmet

Why don't you cast the object 'o' to Form and work from it that rather than trying to do everything via reflection on object?

Regards
Lee

"Ahmet" <ak*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi all;

I have one application in which I read form names from database to be
opened.
I open form with the code below, and call its show method for form to be
shown

but before this, I must set MdiChild property to true to make this form
child

I can call functions as you can see like (show), how can i set.MdiParent = this property of dynamically loaded form ?
Or I can call a form function dynamically with parameter ?
/*------------------------------------------------------------------------*/ public void OpenForm(string pi_form_dll_name)
{
bool bFindForm = false; Assembly formAsm = null;
try
{
this.Cursor = Cursors.WaitCursor;
formAsm = Assembly.LoadFrom(pi_form_dll_name + ".dll");
Type[] ClassTypes = formAsm.GetTypes();
foreach(Type clsType in ClassTypes)
{
if (clsType.IsSubclassOf(typeof(Form)))
{
object o = System.Activator.CreateInstance(clsType);
MethodInfo mi = clsType.GetMethod("Show"); // here can we invoke
property of MdpParent=this instead of invoking method ?
mi.Invoke(o, null); bFindForm = true; break;
}
}
if (bFindForm == false)
{
string sErr = pi_form_dll_name + ".dll does not have " +
"Form-derived class defined";
MessageBox.Show("Form Open Error",sErr);
}
}
catch(System.Exception eSysExc)
{
MessageBox.Show(eSysExc.Message,"Form Open Error");
}
finally
{
this.Cursor = Cursors.Arrow;
}
}
/*------------------------------------------------------------------------*/
helps'll be appreciated..
Ahmet

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: C A Upsdell | last post by:
I have a site where I am setting a style dynamically, using the JS statement: obj.style.backgroundImage = 'url(img/bak_page.jpg)'; where 'obj' is either document.getElementById(id), or...
2
by: R Duke | last post by:
I have tried everything I can think of to change the visible property of a design time created control from a dynamically created control's command event handler. Here is the scenario. I have...
1
by: dx | last post by:
I'm extremely frustrated with ASP.NET...again! To me this should be as simple as setting oCheckBox.Checked = True.. yet for some reason it isn't. I have a user control (ascx) that that has a...
5
by: SalamElias | last post by:
I am creating several chkBoxes dynamically and assigning an event handler in the Page_load as foillows ***************************** Dim chkCatOption As CheckBox = New CheckBox chkCatOption.Text...
6
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to...
4
by: Tim Mackey | last post by:
hi, asp.net 2. can anyone explain why this code does not work in firefox (2.0.0.1), but does work in IE 7. if you hit enter after typing something into the textbox, it should fire the Submit...
8
by: BillE | last post by:
When I create a control dynamically and it grows according to the content, the control Height property still returns the original default control height instead of the height after expanding. ...
7
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a...
3
by: Allen Chen [MSFT] | last post by:
Hi Richard, Quote from Richard================================================== However I also want to be able to remove the panes. I have tried to include this, but find that when I first...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.