0

In vb.net, the Login Form, Splash Screen, and Dialog Form are nice to have. They are available through Visual Studio's Project > Add New Item... dialog.

Is there a way to add these prebuilt forms to a c# project without jumping through hoops?

If need be, the forms can be re-implemented or created in a vb.net project and then instantiated from the main (c#) project, but that is a lot of work if there's an easy workaround.


vb.net project


c# project

5 Answers 5

2

I think using VB.NET forms in C# is not directly possible. But you could put a wrapper around the VB.NET forms and compile it into a DLL. Then you can use the DLL from your C# application. A similar suggestion (but the other way round) is given here.

Edit: Actually you don't need a wrapper. You can use the form from the project directly as shown here.

Sign up to request clarification or add additional context in comments.

3 Comments

This is what I've done to get around the issue in the past. I was hoping that I had missed something simple and there was a c# version of the forms "hidden" somewhere.
Can you clarify what you mean by a "wrapper"? If the forms were in a separate project, why do you think that the C# project couldn't just use new VBForm()?
@John: Sorry, made a mistake. I made an edit for clarification.
2

You can create your own C# versions of the VB templates by (manually) converting the .zip files in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\VisualBasic\Windows Forms\1033.

  1. Copy and unzip the required template
  2. Manually convert the VB code to C# code
  3. Modify, and save the .vstemplate XML file (see also the schema reference)
  4. Compress the files into a new .zip
  5. Drop the C# .zip inside C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Windows Forms\1033

2 Comments

Can you elaborate on the steps required?
Well there's a lot to it (see my edits and msdn.microsoft.com/en-us/library/ms185319.aspx).
0

No, you can't combine multiple languages in one project. Simply create a separate project for your VB.NET forms library.

3 Comments

I know that I can't combine languages in a single project, I was just wondering if there was a similar c# implementation of the vb.net forms (just like you can create a user form in either c# or vb.net).
If there were a similar implementation (from Microsoft) then you would see it in the Add New Item dialog.
look into adding to the using , using Microsoft.VisualBasic I've done this in the past.. just code it in C# LOL
0

you cannot mix VB and C# in the same project but you can combine/group a C# project and a VB.NET project into the same VS solution.

in this case you could have a class library written in vb.net which hosts your special forms and a windows application written in C# which references the other one and uses those forms, provided you make those public.

Comments

0

Only thing I can think of is to make the primary project of your application a VB project. That's the only thing that'll allow you to use the My.Application.SplashScreen property, and you'll only be able to use it from within the VB parts of your app (trying to use Application.SplashScreen from within C# will not compile).

1 Comment

I've used splash screens in c# before doing more or less what is suggested here: social.msdn.microsoft.com/Forums/en-US/winforms/thread/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.