在win appication中将一种形式的文本框值传递给另一种形式 [英] passing a textbox value of one form to another form in win appication

查看:63
本文介绍了在win appication中将一种形式的文本框值传递给另一种形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,
香港专业教育学院获得文本框的值,这是C#形式到vb.net形式.
FYI-
我已经合并了两个项目.
我可以从一个项目访问另一个项目的功能和类.


请帮助我
问候
siv

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

推荐答案

这是有关表单协作的常见问题.最可靠的解决方案是在表单类中实现适当的接口.请查看我过去的解决方案以获取更多详细信息:如何以两种形式在列表框之间复制所有项目 [
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


您将需要从一种形式到另一种形式的引用,或者您需要两种形式来共享消息删除系统(例如,事件聚合器 [
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''.

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

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




通过共享参考,您可以访问任何公开的内容.因此,您可以公开地显示该文本框的文本值,并可以通过C#表单的VBForm属性对其进行访问.




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.


这篇关于在win appication中将一种形式的文本框值传递给另一种形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆