How do Visual Studio 2010 projects work together under the same solution? I'm trying to combine my first four simple projects

StackOverflow https://stackoverflow.com/questions/8022085

  •  22-02-2021
  •  | 
  •  

Pergunta

Good Day All,

I’m new to programming. I’m using Visual Studio 2010. I’m taking into two introduction classes, VB and C# with .Net.

I'm searching for example code of different project forms under the same solution working together at least at my level of understanding. The only alternative that I can fathom is that this is not allowed.

I may need help in forming my question since my searches are all failing. I've listed all my failed search strings at the end of this document.

We have created four school projects with single forms under different solutions that also have classes.

Can the four VB projects be combined under a single solution so that the frmCompany can “.show()” the frmCustomerAccount or the frmMovieRental or the frmPayment . Each of these forms are under their own project but I have “add existing” them into a single solution. I want to know if the multiple project forms can call each other. Or how do you combine projects so that they work together.

Do you use “pathing” when referring or calling across projects within the same solution? I’m trying to move between their forms. If you can do this, how do you make the call between projects? Such as from project1’s form: “project2.frmCustomerAccount.show()” ? and back again by “project1.frmCompany.show()” ?

I’m hoping for simple code examples that shows bouncing between multiple projects' forms under a single solution that I may understand at my intro level.

Thank you for reading, William

Below are my list of Google searches Visual basic 2010 can projects reference other projects forms visual basic 2010 can projects work together visual basic 2010 how do you join projects "visual studio 2010" "multiple projects" tutorial "visual studio 2010" do projects work together call each other? "visual studio 2010" how does one project refer to another within a solution? "visual studio 2010" "how do you use forms from other projects? "visual studio 2010" "how do you integrate projects? "visual studio 2010" "do projects integrate? "visual studio 2010" "do projects tie together? "visual studio 2010" can forms call forms in other projects "visual studio 2010" what relationship do projects have within the same solution "visual studio 2010" "do projects combine?"

Foi útil?

Solução

A Solution is simply a Visual Studio construct meant to help you to do what you just did. Group up a few projects so that you can easily jump back and forth between them. From the compilers standpoint however, the solution doesn't matter.

What matters are referencing the assembly you need and using the correct namespace. So what you need to do in a visual studio setting is to select Add Reference from the context menu of the References node in a project. Then look up the project containing the form you want to call, and add it.

From your calling class you can then either do a

//Header of file with class initializing referenced class.
using Personal.Namespace.Of.Other.Class;

//Within initializing class-method.
var form = new MyForm();
form.Show();

or

var form = new Personal.Namespace.Of.Other.Class.MyForm();
form.Show();

Hope that'll get you on the right track.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top