This article describes a way to open another WinForm project form in a class library or WinForm project. Share to everyone for your reference. Specific as follows:
First, the question:
Suppose the class library or WinForm project is a, and the other WinForm project is B. Add an interface to a, there is a show method, and then write a class B in B to inherit the interface, and override this method, The specific content is to pop up a form. Then instantiate Class B in a In another class A, assign it to the interface in a, and then invoke the Show method of the interface to eject the form specified in B.
It is important to note that project A and project B need to introduce each other's EXE or DLL files.
Second, the implementation of code:
The code is as follows:
Namespace his
{
public interface IShow
{
void Show ();
}
}
Namespace Emrapp
{
public class Cshow:ishow
{
public void Show ()
{
form frm = new form ();
frm. Text = "Test Emrapp window";
frm. Show ();
}
}
}
Namespace his
{
public class Ctransfshow
{
public void AAA ()
{
IShow ish = new Cshow ();
Ish. Show (); Here
}
}
}
Namespace his
{
public partial class Form1:form
{
Public Form1 ()
{
InitializeComponent ();
}
private void Form1_Load (object sender, EventArgs e)
{
Ctransfshow ct = new ctransfshow ();
CT.AAA ();
}
}
}
In addition to the Declaration,
Running GuestArticles are original, reproduced please link to the form of the address of this article
How to open another WinForm project form in a class library or WinForm project
This address: http://www.paobuke.com/develop/c-develop/pbk23316.html
Related content C # How to automatically identify the encoding of a file C # implement polling algorithm instance code bootstrap Mvcpager page style (get requests, refresh pages) WinForm implement a method of dragging a file onto a form
Example tutorials for using the empty () and defalutifempty () usage Analysis C # foundation in C # Tutorial C #. NET Implementing a currency conversion sample C # A summary of several common methods for implementing shortcut keys
How to open another WinForm project form in a class library or WinForm project