How to open another WinForm project form in a class library or WinForm project

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.