Home All Groups Group Topic Archive Search About

Can forms in different projects reference one another?

Author
25 Sep 2006 5:58 PM
MikeB
Me again. Is it possible to have two projects in a solution (ProjA and
ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried
the following, but I get a problem with the reference

  Sub ShowFormB
     Dim frm as new < ? FormB?? various things I tried here>
     frm.Show()
     Me.Close()
  End Sub

Thanks

Author
25 Sep 2006 6:11 PM
Kerry Moorman
MikeB,

ProjA must have a reference to ProjB. In the Solution Explorer window,
right-click ProjA and select Add Reference. From the Add Reference dialog,
click the Projects tab and select ProjB.

Now your ProjA can show a form in ProjB:

      Dim frm As New ProjB.SomeForm
      frm.Show()

Kerry Moorman

Show quoteHide quote
"MikeB" wrote:

> Me again. Is it possible to have two projects in a solution (ProjA and
> ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried
> the following, but I get a problem with the reference
>
>   Sub ShowFormB
>      Dim frm as new < ? FormB?? various things I tried here>
>      frm.Show()
>      Me.Close()
>   End Sub
>
> Thanks
>
>
Author
25 Sep 2006 6:22 PM
Mythran
Show quote Hide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:33D804A6-5033-4324-AC5E-E25881D0CC2C@microsoft.com...
> MikeB,
>
> ProjA must have a reference to ProjB. In the Solution Explorer window,
> right-click ProjA and select Add Reference. From the Add Reference dialog,
> click the Projects tab and select ProjB.
>
> Now your ProjA can show a form in ProjB:
>
>      Dim frm As New ProjB.SomeForm
>      frm.Show()
>
> Kerry Moorman
>
> "MikeB" wrote:
>
>> Me again. Is it possible to have two projects in a solution (ProjA and
>> ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried
>> the following, but I get a problem with the reference
>>
>>   Sub ShowFormB
>>      Dim frm as new < ? FormB?? various things I tried here>
>>      frm.Show()
>>      Me.Close()
>>   End Sub
>>
>> Thanks
>>
>>

This is kinda tricky.  What I would prefer in my own projects would be to
create a separate library project for the shared forms.  This project would
then be referenced by the two winforms projects.  This prevents circular
references from occurring.

HTH,
Mythran
Author
26 Sep 2006 12:46 AM
Dennis
That's all well and good but when you are writing and debugging code, it's a
pain to load the library class and change it's code...also hard to find some
errors.   That's the beauty of putting all your related projects into one
solution at least until you've finished debugging them.
--
Dennis in Houston


Show quoteHide quote
"Mythran" wrote:

>
> "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
> news:33D804A6-5033-4324-AC5E-E25881D0CC2C@microsoft.com...
> > MikeB,
> >
> > ProjA must have a reference to ProjB. In the Solution Explorer window,
> > right-click ProjA and select Add Reference. From the Add Reference dialog,
> > click the Projects tab and select ProjB.
> >
> > Now your ProjA can show a form in ProjB:
> >
> >      Dim frm As New ProjB.SomeForm
> >      frm.Show()
> >
> > Kerry Moorman
> >
> > "MikeB" wrote:
> >
> >> Me again. Is it possible to have two projects in a solution (ProjA and
> >> ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried
> >> the following, but I get a problem with the reference
> >>
> >>   Sub ShowFormB
> >>      Dim frm as new < ? FormB?? various things I tried here>
> >>      frm.Show()
> >>      Me.Close()
> >>   End Sub
> >>
> >> Thanks
> >>
> >>
>
> This is kinda tricky.  What I would prefer in my own projects would be to
> create a separate library project for the shared forms.  This project would
> then be referenced by the two winforms projects.  This prevents circular
> references from occurring.
>
> HTH,
> Mythran
>
>
>
Author
26 Sep 2006 5:41 PM
Mythran
Show quote Hide quote
"Dennis" <Den***@discussions.microsoft.com> wrote in message
news:2336EB31-AD54-4FFD-AA6C-B0559F05A35E@microsoft.com...
> That's all well and good but when you are writing and debugging code, it's
> a
> pain to load the library class and change it's code...also hard to find
> some
> errors.   That's the beauty of putting all your related projects into one
> solution at least until you've finished debugging them.
> --
> Dennis in Houston
>
>
> "Mythran" wrote:
>
>>
>> "Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
>> news:33D804A6-5033-4324-AC5E-E25881D0CC2C@microsoft.com...

Yeah, you would put these shared forms into a project that is part of the
same solution and reference this project as a project reference from the two
winforms projects.

Mythran
Author
25 Sep 2006 6:24 PM
MikeB
Kerry, thank you.

Does this mean that the Projects have to have names consisting of one
word only? Is there a way to (for instance) use "Host Country" and
"Travel Information" as project names?

MikeB

Kerry Moorman wrote:
Show quoteHide quote
> MikeB,
>
> ProjA must have a reference to ProjB. In the Solution Explorer window,
> right-click ProjA and select Add Reference. From the Add Reference dialog,
> click the Projects tab and select ProjB.
>
> Now your ProjA can show a form in ProjB:
>
>       Dim frm As New ProjB.SomeForm
>       frm.Show()
>
> Kerry Moorman
>
> "MikeB" wrote:
>
> > Me again. Is it possible to have two projects in a solution (ProjA and
> > ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried
> > the following, but I get a problem with the reference
> >
> >   Sub ShowFormB
> >      Dim frm as new < ? FormB?? various things I tried here>
> >      frm.Show()
> >      Me.Close()
> >   End Sub
> >
> > Thanks
> >
> >
Author
25 Sep 2006 6:51 PM
Kerry Moorman
MikeB,

You can have mutliple word project names, such as "Host Country". But I
think that the space gets replaced by an underscore by .Net, like this:

     Dim frm As New Host_Country.SomeForm

Kerry Moorman


Show quoteHide quote
"MikeB" wrote:

> Kerry, thank you.
>
> Does this mean that the Projects have to have names consisting of one
> word only? Is there a way to (for instance) use "Host Country" and
> "Travel Information" as project names?
>
> MikeB
>
> Kerry Moorman wrote:
> > MikeB,
> >
> > ProjA must have a reference to ProjB. In the Solution Explorer window,
> > right-click ProjA and select Add Reference. From the Add Reference dialog,
> > click the Projects tab and select ProjB.
> >
> > Now your ProjA can show a form in ProjB:
> >
> >       Dim frm As New ProjB.SomeForm
> >       frm.Show()
> >
> > Kerry Moorman
> >
> > "MikeB" wrote:
> >
> > > Me again. Is it possible to have two projects in a solution (ProjA and
> > > ProjB) and have Form1 in ProjA do a .Show() for Form2 in ProjB? I tried
> > > the following, but I get a problem with the reference
> > >
> > >   Sub ShowFormB
> > >      Dim frm as new < ? FormB?? various things I tried here>
> > >      frm.Show()
> > >      Me.Close()
> > >   End Sub
> > >
> > > Thanks
> > >
> > >
>
>
Author
25 Sep 2006 8:20 PM
Herfried K. Wagner [MVP]
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> schrieb:
> You can have mutliple word project names, such as "Host Country". But I
> think that the space gets replaced by an underscore by .Net, like this:
>
>     Dim frm As New Host_Country.SomeForm

In this case I'd set a more appropriate root namespace in the project
properties.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>