How to call a Form from another project

17,035

Solution 1

You first need to get a reference from project A to project B. To do so, right-click project A, select Add Reference, select tab Projects, and double-click project B.

Now you'll be able to reference the form in project B in project A:

Namespace.FormName.Show()

Solution 2

  1. In your Project A add a reference to Project B (right-click on the project, Add Reference..., click on Projects tab and add Project B).
  2. In your Project A add Imports ProjectBNamespace
  3. Create a variable of type ProjectBClassName, eg. Dim sample As New SampleForm(), in your button click event handler
  4. Inside this event handler call sample.Show() or sample.ShowDialog(). The first option will open a modeless dialog box, while the other one is a modal dialog box.
Share:
17,035

Related videos on Youtube

Michael
Author by

Michael

Updated on August 03, 2022

Comments

  • Michael
    Michael over 1 year

    I have two WinForm projects(A,B) in one solution.

    A project is VB.Net2

    B project is C#.Net4

    They both have Form.

    The A project is set as startup project and has START button. When I press the button I have to activate Form from the B project.

    Any Idea how can Implement it?

    Thank you in advance!