private void listView1_SelectedIndexChanged(object sender, EventArgs e) { listView1.FullRowSelect = true; IDC_DIALOG1 menu1 = new IDC_DIALOG1(); IC_DIALOG2 datas = new IC_DIALOG2(); for (int j = listView1.SelectedIndices.Count - 1; j >= 0; j--) //判断选中哪项 { string listname = listView1.SelectedItems[0].Text; //取出选中的名字 if (listname == "安全设置") { //根据选中的名字来判断用哪一个对话框 this.panel1.Controls.Clear(); //先清空panel当中的所用内容 menu1.TopLevel = false; //去掉对话框的顶级属性 menu1.Dock = System.Windows.Forms.DockStyle.Fill;//让对话框全屏适应panel this.panel1.Controls.Add(menu1); //添加到容器panel当中 menu1.Show(); //显示这个对话框 } else if (listname == "数据管理") { this.panel1.Controls.Clear(); datas.TopLevel = false; datas.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Controls.Add(datas); datas.Show(); } }