Avatar of pugmi16
pugmi16
 asked on

C# WinForm TabControl SelectedIndexChanged not being kicked off when differnt Tabs Are clicked

Hello,
 
    I have a winform that I added a tabcontrol to.... then I added 4 tabs.... I then went into the code behind and added the following:      

     private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            MessageBox.Show("AHHHHHHHH");
        }

See entire Progam below......

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 Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            MessageBox.Show("AHHHHHHHH");
        }
    }

}

when I run this program and click on the different tabs I would expect it to pop up AHHHHHH as this event is triggered....  but I can click away from tab to tab and nothing ever gets triggered.... I set a breakpoint in the SelectedIndexChanged and it never is callled.... what am I doing wrong????

                                                Thanks!
C#

Avatar of undefined
Last Comment
pugmi16

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
p_davis

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
pugmi16

ASKER
Thanks!! I did not have the event handler setup:

            this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.TabControl1_SelectedIndexChanged); in the designer.cs

Thanks for the quick check :)
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23