从控件的调用方法未完全运行. [英] Calling Method from Control not Fully Running.
问题描述
(使用Teleriks''RadPageView)
我在用户控件中有一个创建并填充"RadPageView"的方法.
(Using Teleriks'' RadPageView)
I have a Method inside a usercontrol which creates and populates a "RadPageView".
public void CreateDemoMap()
{
RadPageViewPage pTest = new RadPageViewPage();
pTest.Text = "Live Map (Demo)";
radPageViewX.Pages.Add(pTest);
WebMap wMap = new WebMap();
pTest.Controls.Add(wMap);
MessageBox.Show("TEST");
}
通过相同的形式,但在用户控件之外,我有一个调用Method的按钮.
From the same form but outside of the user control I have a button calling on the Method.
private void radButtonElement4_Click_1(object sender, EventArgs e)
{
ProjectDashControl PDC = new ProjectDashControl();
PDC.CreateDemoMap();
}
该方法可以运行(文本框显示"Test"),但是不会生成RadPageView.
运行本地化方法-我得到了预期的结果,并且工作正常.
The method does run (Textbox Shows "Test") But the RadPageView does not generate.
Running the method localy - I get the intended results and it works fine.
public ProjectDashControl()
{
InitializeComponent();
CreateDemoMap();
}
所以我不确定如何解决这个问题.或与此相关的问题是什么;我正在创建的实例优先于后者吗?不在表单中运行?赞赏或建议-提前致谢.
So I''m not sure how to fix this; or for that matter what the issue is; Is the instance i''m creating taking presedence over the latter? Not running with-in the form? Suggestions or Answers Appreciated - Thanks in Advance.
推荐答案
您必须将变量ProjectDashControl PDC
移到类的全局范围内,否则当方法radButtonElement4_Click_1
结束.
You have to move variableProjectDashControl PDC
to global scope of your class or else GC will collectPDC
when the methodradButtonElement4_Click_1
ends.
将变量ProjectDashControl PDC移动到全局范围并更改为实例.
Moved Variable ProjectDashControl PDC to Global Scope and Changed to Instance.
ProjectDashControl PDC = ProjectDashControl.Instance();
这篇关于从控件的调用方法未完全运行.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!