在运行时隐藏/显示按钮

马特奥普克

在c#和一些图形问题上,我需要您的帮助:我正在开发一个非常简单的应用程序。有一个称为DeltaPregView的独特表单,一个名为DeltaPregController的表单的控制器,以及一个包含项目Main的类:

主类:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;

namespace deltaPreg
{
    static class Program
    {
        [MTAThread]
        static void Main()
        {
            //create the view
            DeltaPregView view = new DeltaPregView();
            //link the view to the APP
            Application.Run(view);
            //initialize the controller of the APP
            DeltaPregController controller = new DeltaPregController(view);
        }
    }
}

查看课程:

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace deltaPreg
{
    public partial class DeltaPregView : Form
    {
        public DeltaPregView()
        {
            InitializeComponent();

        }

        public void init()
        {
            prova.Visible = false;
        }

    }
}

和该视图的控制器:

using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace deltaPreg
{
    class DeltaPregController
    {
        #region variables
        private DeltaPregView view;
        #endregion

        public DeltaPregController(DeltaPregView view)
        {
            this.view = view;
            //start the reading process
            start();
        }
        private void start()
        {
            view.init();
        }
    }
}

我想隐藏名为“ prova”的按钮,但是程序中没有任何变化。我是winforms管理领域的新手,谢谢。

依他索

问题是您在中调用init函数之前先打印表格DeltaPregView

解决此问题的一种方法是替换这些行:

    //link the view to the APP
    Application.Run(view);
    //initialize the controller of the APP
    DeltaPregController controller = new DeltaPregController(view);

到:

    //initialize the controller of the APP
    DeltaPregController controller = new DeltaPregController(view);
    //link the view to the APP
    Application.Run(view);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在运行时显示/隐藏portlet

来自分类Dev

在运行时按钮未显示在MapKitView上

来自分类Dev

在运行时隐藏标签

来自分类Dev

在运行时隐藏Mapbox POI

来自分类Dev

在运行时更改按钮框架

来自分类Dev

在运行时更改按钮框架

来自分类Dev

在运行时构造按钮

来自分类Dev

图表js在运行时通过buttonClick显示/隐藏图例

来自分类Dev

GTK#图像按钮在运行时不显示图像

来自分类Dev

如何在Visual Basic中在运行时更改按钮上显示的图像?

来自分类Dev

在运行时Ax 2012上隐藏枚举元素

来自分类Dev

在运行时Ax 2012上隐藏枚举元素

来自分类Dev

在运行时根据 UISegmented 控件的选择隐藏标签

来自分类Dev

如何在运行时更改按钮标签?

来自分类Dev

在运行时在Highcharts图表中添加按钮

来自分类Dev

Tkinter按钮在运行时“未定义”

来自分类Dev

在运行时单击时如何更改按钮的颜色?

来自分类Dev

在运行时创建动作的工具按钮

来自分类Dev

CEGUI在运行时更改按钮图像

来自分类Dev

Xamarin Forms按钮单击事件在运行时崩溃

来自分类Dev

如何在运行时编辑 WPF 按钮

来自分类Dev

在运行时生成 (n) 个按钮

来自分类Dev

如何在运行时添加和显示JLabel?

来自分类Dev

MenuItem在运行时不显示图像

来自分类Dev

在运行时显示-java.lang.NullPointerException

来自分类Dev

来自xaml的wpf图像未在运行时显示

来自分类Dev

在JSF中在运行时显示警报消息

来自分类Dev

Collectionview在运行时不显示任何内容

来自分类Dev

添加了JButton但在运行时未显示