[英]How to call a method on View layer from Controller layer?
Sorry if this is a supid question. 抱歉,这是一个愚蠢的问题。 I have acquainted with c # for 2 months.
我已经熟悉C#2个月了。 I have created a winform app, which is designed follow by MVC pattern.
我已经创建了一个Winform应用程序,其设计遵循MVC模式。 Now, I get a problem: I want to call a method on View, from Controller layer.
现在,我遇到一个问题:我想从Controller层在View上调用方法。
On View layer, I wanto show Login form when ShowLoginForm() is called. 在视图层上,我想在调用ShowLoginForm()时显示登录表单。
On controller layer, I have a timer control. 在控制器层,我有一个计时器控件。 I set schedule time to import my data to DB automatically.
我设置了计划时间以自动将数据导入数据库。 because my data is downloaded from my server, I need declare username\\password via Login form on View.
因为我的数据是从服务器下载的,所以我需要通过View上的Login表单声明username \\ password。
private void ImportToDB()
{
if (myControllerObject.GetServerConnection() == null)
{
//call ShowLoginForm() on View
}
//my code which i want to do
}
How do I do to solve this problem? 如何解决这个问题? Could you suggest me some technical (I thought delegate, callback)?
您能建议我一些技术性的问题吗(我认为是委托,回调)?
As per the MVC pattern: 按照MVC模式:
The easiest solution I can think of is adding a dedicated bool ShowLoginForm
property in the model. 我能想到的最简单的解决方案是在模型中添加专用的
bool ShowLoginForm
属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.