Groups | Blog | Home
all groups > dotnet general > february 2007 >

dotnet general : Integrating VB.net forms into C#


Terrance
2/28/2007 11:43:20 AM
I have a question about functionality I was wondering if anyone ever tried.
Here is my problem/question. I'm currently in the motions of learning C# with
that said I created a windows application which has a parent form. I have
several small data eccentric applications in VB that I would like to
implement in C# but I don't want to go back and recreate all the forms and
recode.

Is there a way for me to add the VB forms into the C# mdiParent form. I
don't mind placing in the code for launching the forms I just don't wanna go
back and re-write or create all of the forms from scratch. Can I make the Vb
forms dll's and implement them that way? Has anyone ever tried this? Thanks.
--
RobinS
2/28/2007 2:40:52 PM
I doubt it. I had trouble even copying and pasting code from VB2005 to C#.
Some lines didn't work even though they were identical, but then when I
typed the same darned thing on the next line, it did work. I mean the same
exact darn thing.

Robin S.
---------------------------------
[quoted text, click to view]

RobinS
2/28/2007 2:41:59 PM
Oh, one thing you *can* try is opening the form in design mode in VB, then
select all the controls and hit Ctrl-C to copy them. Then open a form in
design mode in C#, and hit Ctrl-V to paste them in. It won't give you the
code behind, but at least you won't have to recreate the forms. I'm not
100% sure it will work, but I'd be surprised if it didn't.

Robin S.
---------------------------
[quoted text, click to view]

Terrance
2/28/2007 4:40:05 PM
Thanks for your help. I may have found a way. If I create the form as a user
control I can apply the entire user control to a form in C#. I tested this
earlier. I created a user control with a text field and buttons. Behind the
button I placed a simple message box. By the way, since it's a user control I
had to type out the entire syntax for the message box which was
System.Windows.Forms.Messagebox. Anyhow, I applied the user control a form in
C# and it worked. When I clicked the button the Messagebox showed up. I'm
going to have to experiment some more.

I figured it was possible since the languages are suppose to be integrated.
Anyhow, if anyone has any more suggestions then let me know.


--
TC


[quoted text, click to view]
RobinS
2/28/2007 8:57:50 PM
Geez, having the whole thing be a user control adds a level of complexity
to it that I wouldn't want to deal with. I'm still voting for the copy &
paste method... ;-)

Robin S.
-------------------------
[quoted text, click to view]

AddThis Social Bookmark Button