|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Bring in a form from another solution/projectI want to include a form and it's code that resides in another
solution/project into my current solution such that I can Display said form as a modeless dialog of my main form. How is best to get that form and code into my main solution? After you tell me how to do that... Will it be a problem that both forms are called form1? Thanks! Bob Having two forms with the same name in the same project won't work.
Here is an approach for adding an existing Form to a project. 1. Rename the form in the source project. (Only when it has the same name as a form in your main project.) 2. Then, from the destination project right click the name of the project in the Solution Explorer panel and select Add -> Existing Item... 3. An 'Add Existing Item' dialog will open. Use it to navigate to the source project directory. 4. Find the files for the Form you wish to pull into the destination project. There will be three, each with the same name but with different file extensions (.vb, .resx, .designer.vb). 5. Select all three then click the Add button. The form is added to your main project. As far as showing the form you imported as a modeless dialog from your main form: When you call the form use [Form].ShowDialog instead of [From].Show. Show quoteHide quote "BobAchgill" <BobAchg***@discussions.microsoft.com> wrote in message news:D7D7586C-16C9-4093-94F8-DC904E9808F9@microsoft.com... >I want to include a form and it's code that resides in another > solution/project into my current solution such that I can Display said > form > as a modeless dialog of my main form. > > How is best to get that form and code into my main solution? > > After you tell me how to do that... > > Will it be a problem that both forms are called form1? > > Thanks! > > Bob Mike.
After I do these steps all I get is a blank form resulting from STEP 3. Can you see what I am doing wrong? I even tried just adding a new form2 directly in the project and tried calling it but still only got a blank form come up. Maybe I am not qualifying the form correctly in the statement... RenamedForm.ShowDialog() STEP 1: Rename the Form in source project Right click on Form1 -> Properties rename -> "RenamedForm" STEP 2: From destination project add the RenamedForm from the source project Project -> Add -> Add existing item -> browse and select and open: RenamedForm.vb RenamedForm.resx ***NOTE - Only found two files to select ***NOTE - I had to change all occurances of "Form1" in code of RenamedForm from Form1 to RenamedForm since they seemed to be conflicting with the real form 1. I guess I should have done that as a part of step 1?? STEP 3: In the code of Form1 call RenamedForm using a button click: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click ' Create an instance of the form to be owned. Dim RenamedForm As New Form ' Set the text of the form to identify it is an owned form. RenamedForm.Text = "Owned Form" ' Add RenamedForm to array of owned forms. Me.AddOwnedForm(RenamedForm) ' Show the owned form. RenamedForm.ShowDialog() End Sub Show quoteHide quote "Mike McIntyre" wrote: > Having two forms with the same name in the same project won't work. > > Here is an approach for adding an existing Form to a project. > > 1. Rename the form in the source project. (Only when it has the same name as > a form in your main project.) > > 2. Then, from the destination project right click the name of the project in > the Solution Explorer panel and select Add -> Existing Item... > > 3. An 'Add Existing Item' dialog will open. Use it to navigate to the source > project directory. > > 4. Find the files for the Form you wish to pull into the destination > project. There will be three, each with the same name but with different > file extensions (.vb, .resx, .designer.vb). > > 5. Select all three then click the Add button. The form is added to your > main project. > > As far as showing the form you imported as a modeless dialog from your main > form: > > When you call the form use [Form].ShowDialog instead of [From].Show. > > -- > Mike > > Mike McIntyre [MVP] > http://www.getdotnetcode.com > > > "BobAchgill" <BobAchg***@discussions.microsoft.com> wrote in message > news:D7D7586C-16C9-4093-94F8-DC904E9808F9@microsoft.com... > >I want to include a form and it's code that resides in another > > solution/project into my current solution such that I can Display said > > form > > as a modeless dialog of my main form. > > > > How is best to get that form and code into my main solution? > > > > After you tell me how to do that... > > > > Will it be a problem that both forms are called form1? > > > > Thanks! > > > > Bob > > > Mike,
Got it! When I said instead... Dim RenamedForm As New RenamedForm Thanks a million! Show quoteHide quote "BobAchgill" wrote: > Mike. > > After I do these steps all I get is a blank form resulting from STEP 3. Can > you see what I am doing wrong? I even tried just adding a new form2 directly > in the project and tried calling it but still only got a blank form come up. > Maybe I am not qualifying the form correctly in the statement... > RenamedForm.ShowDialog() > > > > STEP 1: Rename the Form in source project > > Right click on Form1 -> Properties rename -> "RenamedForm" > > > STEP 2: From destination project add the RenamedForm from the source project > > Project -> Add -> Add existing item -> browse and select and open: > RenamedForm.vb > RenamedForm.resx > > ***NOTE - Only found two files to select > > ***NOTE - I had to change all occurances of "Form1" in code of RenamedForm > from Form1 to RenamedForm since they seemed to be conflicting with the real > form 1. I guess I should have done that as a part of step 1?? > > > STEP 3: In the code of Form1 call RenamedForm using a button click: > > > Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As > System.EventArgs) Handles Button1.Click > > > ' Create an instance of the form to be owned. > Dim RenamedForm As New Form > ' Set the text of the form to identify it is an owned form. > RenamedForm.Text = "Owned Form" > ' Add RenamedForm to array of owned forms. > Me.AddOwnedForm(RenamedForm) > ' Show the owned form. > RenamedForm.ShowDialog() > > End Sub > > > > "Mike McIntyre" wrote: > > > Having two forms with the same name in the same project won't work. > > > > Here is an approach for adding an existing Form to a project. > > > > 1. Rename the form in the source project. (Only when it has the same name as > > a form in your main project.) > > > > 2. Then, from the destination project right click the name of the project in > > the Solution Explorer panel and select Add -> Existing Item... > > > > 3. An 'Add Existing Item' dialog will open. Use it to navigate to the source > > project directory. > > > > 4. Find the files for the Form you wish to pull into the destination > > project. There will be three, each with the same name but with different > > file extensions (.vb, .resx, .designer.vb). > > > > 5. Select all three then click the Add button. The form is added to your > > main project. > > > > As far as showing the form you imported as a modeless dialog from your main > > form: > > > > When you call the form use [Form].ShowDialog instead of [From].Show. > > > > -- > > Mike > > > > Mike McIntyre [MVP] > > http://www.getdotnetcode.com > > > > > > "BobAchgill" <BobAchg***@discussions.microsoft.com> wrote in message > > news:D7D7586C-16C9-4093-94F8-DC904E9808F9@microsoft.com... > > >I want to include a form and it's code that resides in another > > > solution/project into my current solution such that I can Display said > > > form > > > as a modeless dialog of my main form. > > > > > > How is best to get that form and code into my main solution? > > > > > > After you tell me how to do that... > > > > > > Will it be a problem that both forms are called form1? > > > > > > Thanks! > > > > > > Bob > > > > > >
Multi-User Data App Architecture
How to use one datagrid to update/insert into another Migrating to VS 2005 cant assign variable values to property in Class file timer1.stop convert BASIC to VB.NET VS 2005 SP1? C++ DLL Usage (p/invoke?) How to Insert field and value into another grid InvalidCastException |
|||||||||||||||||||||||