怎么触发DataGridView显示表格        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection conn = new SqlConnection("server=.;database=StudentManager;uid=;pwd=");
            SqlDataAdapter sda = new SqlDataAdapter("select * from Teacher", conn);
            DataSet ds = new DataSet();
            sda.Fill(ds, "Teacher");
            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }我这段代码为什么没有执行进去呢。 我想在子窗体现实连接数据库后现实表格子窗体代码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;
using System.Data.SqlClient;namespace 学生信息管理系统
{
    public partial class teacher_message_windows : Form
    {
        public teacher_message_windows()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            //center_Windows c_w = new center_Windows();
            //c_w.Show();
        }        private void teacher_message_windows_Load(object sender, EventArgs e)
        {        }        private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
        {        }        private void button3_Click(object sender, EventArgs e)
        {        }        private void button2_Click(object sender, EventArgs e)
        {         
            teacher_course_windows t_c_w = new teacher_course_windows();
            //t_c_w.MdiParent = this;
            //t_c_w.WindowState = FormWindowState.Maximized;
            t_c_w.Show();
            center_Windows c_w = new center_Windows();          
            c_w.Hide();
        }        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            SqlConnection conn = new SqlConnection("server=.;database=StudentManager;uid=;pwd=");
            SqlDataAdapter sda = new SqlDataAdapter("select * from Teacher", conn);
            DataSet ds = new DataSet();
            sda.Fill(ds, "Teacher");
            dataGridView1.DataSource = ds.Tables[0];
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
        }
    }
}
父窗体代码
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;
using System.Data.SqlClient;
namespace 学生信息管理系统
{
    public partial class center_Windows : Form
    {
        public center_Windows()
        {
            InitializeComponent();
            this.IsMdiContainer = true;
        }        private void 系统管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {        }        private void 帮助ToolStripMenuItem_Click(object sender, EventArgs e)
        {        }        private void 退出系统ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }        private void 教师信息管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            teacher_message_windows t_m_w = new teacher_message_windows();
            t_m_w.MdiParent = this;
            t_m_w.WindowState = FormWindowState.Maximized;
            t_m_w.Show();
        }        private void center_Windows_Load(object sender, EventArgs e)
        {        }
    }
}