我在TabControl中切换页面时,怎么SelectedIndexChanged事件没有触发?
不解!
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void tabControl1_SelectedIndexChanged(object sender,EventArgs e)
{
switch (this.tabControl1.SelectedIndex)
{
case 0:
this.textBox1.Text = "1";
break;
case 1:
this.textBox1.Text = "2";
break;
}
} }
}
不解!
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void tabControl1_SelectedIndexChanged(object sender,EventArgs e)
{
switch (this.tabControl1.SelectedIndex)
{
case 0:
this.textBox1.Text = "1";
break;
case 1:
this.textBox1.Text = "2";
break;
}
} }
}
this.tabControl1.SelectedIndexChanged += new EventHandler(tabControl1_SelectedIndexChanged);
tabControl1.SelectedIndexChanged += new EventHandle(tabControl1_SelectedIndexChanged);
当你在属性窗格的事件处双击以后,因为设计器会为我们自动生成以上这段代码,并写在designer.cs文件中,一般情况下是看不到,也不会去关注的。