private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["导师姓名"].Index) { //点击导师姓名查看导师信息 DPersonalInformationPreview dPersonalInformation = new DPersonalInformationPreview(teacher.TeaNo) { TopLevel = false, FormBorderStyle = FormBorderStyle.None, Dock = DockStyle.Fill }; //dPersonalInformation.teaNo = teacher.TeaNo; this.Controls.Clear(); this.Controls.Add(dPersonalInformation); dPersonalInformation.Show(); } /*else if (e.ColumnIndex == dataGridView1.Columns["操作1"].Index) * { * //点击选择弹出志愿序号进行选择 * //dataGridView1.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.Blue;//点击后该行颜色改变 * dataGridView1["操作1", e.RowIndex].Value = "已选择"; * } * else if (e.ColumnIndex == dataGridView1.Columns["操作2"].Index) * { * dataGridView1["操作1", e.RowIndex].Value = "选择"; * }*/ }
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == dataGridView1.Columns["导师姓名"].Index) { //点击导师姓名查看导师信息 DPersonalInformationPreview dPersonalInformation = new DPersonalInformationPreview(teacher.TeaNo) { TopLevel = false, FormBorderStyle = FormBorderStyle.None, Dock = DockStyle.Fill }; //dPersonalInformation.teaNo = teacher.TeaNo; this.Controls.Clear(); this.Controls.Add(dPersonalInformation); dPersonalInformation.Show(); } }
private void button2_Click(object sender, EventArgs e) { this.initButton(); this.button2.BackColor = Color.FromArgb(95, 129, 174); DPersonalInformationPreview cform = new DPersonalInformationPreview();//实例化一个子窗口 //设置子窗口不显示为顶级窗口 cform.TopLevel = false; //设置子窗口的样式,没有上面的标题栏 cform.FormBorderStyle = FormBorderStyle.None; //填充 cform.Dock = DockStyle.Fill; //清空控件 this.pnlCenter.Controls.Clear(); //加入控件 this.pnlCenter.Controls.Add(cform); //让窗体显示 cform.Show(); // try // { // this.initButton(); // this.button2.BackColor = Color.FromArgb(95, 129, 174); // Monitor.Enter(this.lockObj); // if (!formSwitchFlag) // { // formSwitchFlag = true; // this.ShowForm(pnlCenter, form2); // formSwitchFlag = false; // } // else // { // return; // } // } //#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 // catch (System.Exception ex) //#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 // { // // // } // finally // { // Monitor.Exit(this.lockObj); // } }
private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { teacher.TeaNo = dataGridView1["工号", 0].Value.ToString(); if (e.ColumnIndex == dataGridView1.Columns["TeaName"].Index) { DPersonalInformationPreview dPersonalInformation = new DPersonalInformationPreview(teacher.TeaNo) { TopLevel = false, FormBorderStyle = FormBorderStyle.None, Dock = DockStyle.Fill }; //dPersonalInformation.teaNo = teacher.TeaNo; this.Controls.Clear(); this.Controls.Add(dPersonalInformation); dPersonalInformation.Show(); } else if (e.ColumnIndex == dataGridView1.Columns["Control"].Index) { MessageBox.Show("test"); } }