Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Forms
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!");
        }
 
    }
}
Posted 19-Oct-12 2:17am
Edited 19-Oct-12 2:51am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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();
}
 
Thanks to Rawling on stackoverflow Smile | :)
  Permalink  

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

  Print Answers RSS
0 BillWoodruff 330
1 Mathew Soji 309
2 Maciej Los 295
3 DamithSL 225
4 Afzaal Ahmad Zeeshan 217
0 OriginalGriff 6,369
1 Sergey Alexandrovich Kryukov 5,973
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,025


Advertise | Privacy | Mobile
Web02 | 2.8.1411019.1 | Last Updated 19 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100