在表单之间共享值 [英] Sharing values between forms

查看:78
本文介绍了在表单之间共享值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


请原谅我的无知,因为这是我应该知道的事情,但我很不清楚。我有一个基于MDI的应用程序。它是设置的,所以用户打开一个文件

并创建主子表单。一旦打开一个(或更多)

属性表单就可以打开。在属性表单和主子表单之间共享数据的最佳方法是什么?b $ b?当在属性表单中修改值时,我需要提醒

主子表单,以便我可以修改子表单内容的




希望我有意义。感谢您的帮助,我真的很感激。


谢谢,

尼克

Hello,

Please pardon my ignorance as this is something I should know, but I''m a
little unclear. I have an MDI based app. It is setup so the user opens a file
and the main child form is created. Once that is opened one (or more)
properties forms can be opened. What is the best method for sharing data
between the properties forms and the main child form? I need to alert the
main child form when a value is modified in a properties form so I can modify
the contents of the child form.

Hopefully I''m making sense. Thanks for any help, I really appreciate it.

Thanks,
Nick

推荐答案

这可以通过事件&与会代表。参见例如
http://www1.cs.columbia.edu/~eaddy/p...j-feb01.htm#l5

" Nick" < NI ******** @ nospam.nospam>在消息中写道

news:85 ********************************** @ microsof t.com ...
This can be done with events & delegates. See e.g.
http://www1.cs.columbia.edu/~eaddy/p...j-feb01.htm#l5
"Nick" <ni********@nospam.nospam> wrote in message
news:85**********************************@microsof t.com...
你好,

请原谅我的无知,因为这是我应该知道的,但我不太清楚。我有一个基于MDI的应用程序。它是设置的,所以用户打开一个
文件
并创建主子表单。一旦打开,就可以打开一个(或多个)
属性表单。在属性表单和主子表单之间共享数据的最佳方法是什么?我需要在属性表单中修改值时提醒
主子表单,以便我可以修改子表单的内容。

希望我'有道理。感谢您的帮助,我真的很感激。

谢谢,
Nick
Hello,

Please pardon my ignorance as this is something I should know, but I''m a
little unclear. I have an MDI based app. It is setup so the user opens a
file
and the main child form is created. Once that is opened one (or more)
properties forms can be opened. What is the best method for sharing data
between the properties forms and the main child form? I need to alert the
main child form when a value is modified in a properties form so I can
modify
the contents of the child form.

Hopefully I''m making sense. Thanks for any help, I really appreciate it.

Thanks,
Nick



Nick,
Nick,
在属性
表单和主子表单之间共享数据的最佳方法是什么?
What is the best method for sharing data between the properties
forms and the main child form?




1.存储在创建

时传递给每个表单的类中的数据。

2.创建在更改属性时可以触发的事件。

3.在创建主表单时创建类的实例,并在主子表单中绑定事件到方法,以便在任何人更改时

a属性主要子表单被通知。


使用单独的类也可以防止表单彼此知道

,在大多数情况下是好东西。


Dave



1. Store the data in a class that is passed to each of the forms upon
creation.
2. Create events that can be fired when the properties are changed.
3. Create an instance of the class when your main form is created and tie
the events to method within the main child form, so that when anyone changes
a property the main child form is notified.

Using a separate class also prevents the forms from having to know about
each other, which in most cases is a good thing.

Dave


嗨Nick,

欢迎来到MSDN新闻组!


从我的经验来看,自从a ll MDI中的表单是在单个线程中,如果我们想在这些表单之间共享数据,我们可以使用全局变量来实现目标。

>
如果我们想通知表格相关数据已被修改,我们可以发布/发送消息或使用事件&代表们这样做。


我也浏览一些来自互联网的文章并希望它对你有所帮助。

标题:AC#进程间同步框架和沟通

网址: http:// www。 codeproject.com/csharp/csthreadmsg.asp


标题:DevGlobalCache - 一种在进程之间缓存和共享数据的方法

URL: http://www.codeproject.com/dotnet/globalcache.asp


我希望以上信息对您有所帮助。如果您有任何疑问,请随时告诉我们。我期待着您的回音。
。谢谢!


最诚挚的问候,


Terry Fei [MSFT]

微软社区支持

安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)
Hi Nick,
Welcome to MSDN Newsgroup!

From my experience, since all the forms in MDI are in a single thread, if
we want to share data between these forms, we could use global variable to
achieve the goal.
If we want to notify forms that relevant data has been modified, we could
post/send message or use events & delegates to do it.

I also browse some articles from internet and hope it''s helpful for you.
Title: A C# Framework for Interprocess Synchronization and Communication
URL: http://www.codeproject.com/csharp/csthreadmsg.asp

Title: DevGlobalCache - A way to Cache and Share data between processes
URL: http://www.codeproject.com/dotnet/globalcache.asp

I hope the above information is helpful for you. If you have any questions
or concerns, please feel free to let me know. I am looking forward to
hearing from you. Thanks!

Best Regards,

Terry Fei [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


这篇关于在表单之间共享值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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