I have a c# and vb .net solution. I need to use the c# form inside vb form as a tab. How can I do this?
-
1maybe this will help: http://stackoverflow.com/questions/1278024/mixing-c-vb-in-the-same-project – Roger Apr 12 '11 at 04:47
-
What is "c# form inside vb form as a tab"? – BoltClock Apr 12 '11 at 04:47
-
I mean to say that I need to use the content of the c# form as a tab in VB .net – Vicky Apr 12 '11 at 04:52
4 Answers
You could create one of the forms in a separate class library or as a user control in a separate class library and just reference it from within your application. Each project in your solution can be either VB.Net or C#, so it works both ways...
In a simple example solution you could have the following projects
- MyApp.CSharpControls - Project in C#
- MyApp.VBControls - Project in Vb.Net
- MyApp.UI - Project in either C# or VB.Net which can reference either of the other control projects
Edit
I'm presuming winforms??

- 9,393
- 11
- 59
- 73
-
3You don't even have to convert it to class library project. The vb solution can add a reference to the .exe generated by the c# solution and use any of the public types in that c# solution. It will help to convert the c# form to a user control, though. – Joel Coehoorn Apr 12 '11 at 04:54
You would need to have Visual Studio Professional to do something like this.
Instead I suggest you use this site to convert your C#.net to VB.net http://www.developerfusion.com/tools/convert/csharp-to-vb/

- 13,492
- 4
- 23
- 36
No, you can't.
I suggest to encapsulte the the c#-Form into a separate assembly. Create a UserControl to use it inside the other application or if you need the complete form, encapsulte it into a DLL and export a Show/ShowDialog() method.

- 4,487
- 3
- 41
- 51
-
2You can add a reference to a project for plain .Net exe files, as well as class library dlls, and still use any public type in that exe file. There's no special work involved for that, it's still just an assembly. – Joel Coehoorn Apr 12 '11 at 04:55
-
4Of course this is possible, but I try to prevent(or don't like) to instantiate public classes from an exe-file. This was a suggestion, not a "what is possible". The sentence 'No, you can't' refers to the mixture of c# and vb in one solution. – Markus Apr 12 '11 at 05:01
-
-
I did it by adding the .exe file of VB project as a reference in the C# project and called the Form.Show() of the VB project.

- 1,657
- 6
- 23
- 33