Click here to Skip to main content
15,915,019 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
dear all,
ive to get the textbox value which is in c# form to vb.net form.
FYI-
i ve merged two projects.
i can able to acess the fuctions and classes from one project to another.


kindly help me out
regards
siv
Posted

This is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

—SA
 
Share this answer
 
Comments
[no name] 13-Dec-11 11:38am    
+5Good answer. Wish I had a ref collection as you do. Maybe someday :P
Sergey Alexandrovich Kryukov 13-Dec-11 12:34pm    
Thank you, Collin.
--SA
You will need a reference from one of the forms to the other or you will need both forms to share a message deleivery system (e.g. an event aggregator[^]

I would recoment the earlier as it is much easier to impliment and you likely are new to programming (no offence).

So to do this the object that is building the forms will need to tell at minimum one of them about the other. Once this is done, the one that holds the reference can update the others data.

so your VB could contain a reference to your C# form and then access an exposed proeprty that gets access to the text box.

The object that is opening or controlling both forms sets up the references. If it is not a single object then you will have to find a way to push the reference down from a point they both share, e.g. where the application starts 'Main'.

C#
VBForm vbForm = new VBForm();
CSharpForm cSharpForm = new CSharpForm();
vbForm.TheCSharpForm = cSharpForm;

...
//You can now do your 'Show'



By sharing the reference the one can access anything you expose. So you can expose the Text Value of said text box publiclly and get access to it from the VBForm property in the C# form.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900