Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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:

C#
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!");
        }

    }
}
Posted
Updated 19-Oct-12 1:51am
v2

 
Share this answer
 
This is the solution:

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


Thanks to Rawling on stackoverflow :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900