在父表单中传递显示选项更改以影响子表单显示信息的方式 [英] Passing display option change in parent form to impact the way child form display information
问题描述
我需要能够将父表单中"variableDisplayOption_SelectedIndexChanged"生成的索引传递给5个子表单中的3个,从而对信息在子表单内部的显示方式进行了修改.
我在看pierrecor的文章将数据传回呼叫表单".
从本文提供的代码开始,我一直在寻找一种修改它的方法以实现我的目标.目的是能够发送由父表单的菜单中的选择更改产生的信息,以便子表单将根据父表单中的索引更改来修改其中显示的数据的参数.
我要解决的问题之一是,如果子窗体已经打开,则需要更改该窗体.
谢谢,
I need to be able to pass the index generated from a "variableDisplayOption_SelectedIndexChanged" in the parent form to 3 out of 5 child form, resulting a modification in the way the information is displayed inside the child form.
I was looking at the article "Pass data back to the calling form" by pierrecor.
Starting with the code supplied in the article, I was looking in a way to modify it to achieved my goal. The goal is to be able to send the information generated by a change of selection in the menu of the parent form so the child form will modify the parameter of the data displayed in it, according to the index change in the parent form.
One of the problem that I''m trying to solve is, if the child form is already open, I need the form to change.
Thanks,
推荐答案
确定,所以正确的方法是在两种形式中都创建Property
并根据需要设置值.
如果您想要一些快速而肮脏的方法,
1.在所有3个子窗体中创建一个public static index
变量
2.并在选定索引更改后从父窗体设置变量.
3.现在,在子窗体上的Form_Activated
事件中读取公共静态变量的值.
完成此工作后,您可以使用get
和set
选项将公共静态变量更改为实际的Property变量.
OK so the proper way is to createProperty
in both the forms and set the values as needed.
If you want some quick and dirty way then,
1. create apublic static index
variable in all the 3 child form
2. and set the variable from parent form after the selected index changed.
3. now read the value of the public static variable inForm_Activated
event on child form.
after this works you can change the public static variable to actual Property variable withget
andset
options.
这篇关于在父表单中传递显示选项更改以影响子表单显示信息的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!