473,395 Members | 1,936 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,395 software developers and data experts.

MdiParent and InvokeMember...

How can I get a form in a class library to become an MDI Child of the main
application? I've tried the following, but does not work:

Class Library...
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public static bool
DisplayForm(System.Windows.Forms.Form theMDIParent)
{
Form1 f = new Form1();
f.MdiParent = theMDIParent;
f.ShowDialog();
f.Close();
return true;
}
}

In Main App...
Assembly asm = Assembly.LoadFile(@"c:\Documents and Settings\rvasquez\My
Documents\Visual Studio
Projects\TestMDIForms\OtherForms\bin\debug\OtherFo rms.dll");
Type t = asm.GetType("OtherForms.Class1");
object result = null;
object[] arguments = {this};
result = t.InvokeMember("DisplayForm",BindingFlags.InvokeMe thod, null,
result, arguments);
Nov 17 '05 #1
2 2377
possibly setting f.TopLevel = false; may be neccesary, it is when immitating
mdi on a normal form. Also and also guessing it mght be neccesary to set the
mdiclient as the parent rather than setting mdiparent. I did a immitation
mdi app that needed this behaviour to get a form to act as a child form,
whether it works with a proper mdi app I can only guess at.

Hope something is useful.

Martin.

"Robert Vasquez" <Ro***********@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
How can I get a form in a class library to become an MDI Child of the main
application? I've tried the following, but does not work:

Class Library...
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public static bool
DisplayForm(System.Windows.Forms.Form theMDIParent)
{
Form1 f = new Form1();
f.MdiParent = theMDIParent;
f.ShowDialog();
f.Close();
return true;
}
}

In Main App...
Assembly asm = Assembly.LoadFile(@"c:\Documents and Settings\rvasquez\My
Documents\Visual Studio
Projects\TestMDIForms\OtherForms\bin\debug\OtherFo rms.dll");
Type t = asm.GetType("OtherForms.Class1");
object result = null;
object[] arguments = {this};
result = t.InvokeMember("DisplayForm",BindingFlags.InvokeMe thod, null,
result, arguments);

Nov 17 '05 #2
Martin, thank you for your reply. I found out my mistake to be the
following...

f.ShowDialog();

instead of...

f.Show();

"Martin Stainsby" wrote:
possibly setting f.TopLevel = false; may be neccesary, it is when immitating
mdi on a normal form. Also and also guessing it mght be neccesary to set the
mdiclient as the parent rather than setting mdiparent. I did a immitation
mdi app that needed this behaviour to get a form to act as a child form,
whether it works with a proper mdi app I can only guess at.

Hope something is useful.

Martin.

"Robert Vasquez" <Ro***********@discussions.microsoft.com> wrote in message
news:8E**********************************@microsof t.com...
How can I get a form in a class library to become an MDI Child of the main
application? I've tried the following, but does not work:

Class Library...
public class Class1
{
public Class1()
{
//
// TODO: Add constructor logic here
//
}
public static bool
DisplayForm(System.Windows.Forms.Form theMDIParent)
{
Form1 f = new Form1();
f.MdiParent = theMDIParent;
f.ShowDialog();
f.Close();
return true;
}
}

In Main App...
Assembly asm = Assembly.LoadFile(@"c:\Documents and Settings\rvasquez\My
Documents\Visual Studio
Projects\TestMDIForms\OtherForms\bin\debug\OtherFo rms.dll");
Type t = asm.GetType("OtherForms.Class1");
object result = null;
object[] arguments = {this};
result = t.InvokeMember("DisplayForm",BindingFlags.InvokeMe thod, null,
result, arguments);


Nov 17 '05 #3

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

Similar topics

0
by: Jared Hagel | last post by:
I can't use Type.InvokeMember(...) on a remote object. But when I use Type.InvokeMember(...) on a non-remote object in the exact same way, I don't have a problem. Does someone know what I'm...
0
by: Alex Zhitlenok | last post by:
Hi, On Google, one can find a lot of statements that Invoke and InvokeMemeber work alike. However, my own experience contradicts this statement. 1. Surprisingly, Invoke and InvokeMember methods...
3
by: Patrick Ireland | last post by:
I am dynamically loading a class. One of the methods of the class takes a short * (by reference) argument. However, the InvokeMember call used to invoke the method of the class passings arguments...
4
by: Howard Kaikow | last post by:
I am trying to retrive some WMI properties using Option Strict On. This requires the use of InvokeMember. I know that there are alternative ways to get the values, but I want to learn how to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.