从不同形式编辑可见性选项卡控件 [英] Edit visibility tab control from different form

查看:246
本文介绍了从不同形式编辑可见性选项卡控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在其他形式的按钮单击事件上启用/禁用选项卡控件对象的可见性.我对如何执行此操作有些迷惑,谁能给我一个很好的方法示例?我尝试了几种方法:将tabcontrol公开,调用设置该控件的公共函数.

预先感谢,

例如;我的主要形式是以下代码:

I am trying to enable/disable the visibility of a tab control object on a button click event on a different form. I am a bit lost on how to do this, could anyone give my an example of a good way to do this? I tried several things like: making the tabcontrol public, calling a public function which set the control.

Thanks in advance,

For example; I have this code in my main form:

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

namespace Events
{
    public delegate void LinkToEventHandler();

    public partial class frmEventGenerate : Form
    {
        public static event LinkToEventHandler Evt;

        public frmEventGenerate()
        {
            InitializeComponent();
            Evt += new LinkToEventHandler(ReceiveEvent);
            SendEvent();
        }

        public static void SendEvent()
        {
            if (Evt != null)
            {
                Evt();
            }
        }

        public void ReceiveEvent()
        {
            System.Console.WriteLine("Received Event - This works ok");
        }
    }
}



并在子窗体中:



and in the childform:

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

namespace Events
{
    public partial class frmEventReceive : Form
    {
        public frmEventReceive()
        {
            InitializeComponent();
            frmEventGenerate frmGen = new frmEventGenerate();
        }

        public void ReceiveEvent()
        {
            System.Console.WriteLine("I want to be able to receive the even here!");
        }

    }
}

推荐答案

尝试以下方法:-
http://forums.asp.net/t/1620618.aspx/1 [ ^ ]
try this one :-
http://forums.asp.net/t/1620618.aspx/1[^]


这是解决方案:

This is the solution:

// In menu form
private void button1_Click(object sender, EventArgs e)
{
    var mainForm = this.MdiParent as STP2Main;
    if (mainForm != null)
        mainForm.set();
    this.Close();
}



感谢Rawling在stackoverflow:)



Thanks to Rawling on stackoverflow :)


这篇关于从不同形式编辑可见性选项卡控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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