我创建了一个使灯箱效果生效的表单。在创建此灯箱表单后,我创建了另一个表单。
//Execute from parent form
Form f = new Form();
f.ShowInTaskbar = false;
f.BackColor = Color.Black;
f.Size = this.Size;
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
f.StartPosition = FormStartPosition.CenterParent;
f.Opacity = 0.6;
f.ShowDialog(); // Open Modal window
notificationSize nds = new notificationSize();
nds.Show(); // Open another form on Modal Dialog
创建灯箱表单后,它不会显示另一个表单nds。只需showind the lightbox模态对话框。
如何在模态表单上显示表单?
答案 0 :(得分:2)
展示您的孩子"将TopLevel
设置为false:
Form f = new Form();
f.ShowInTaskbar = false;
f.BackColor = Color.Black;
f.Size = this.Size;
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
f.StartPosition = FormStartPosition.CenterParent;
f.Opacity = 0.6;
notificationSize nds = new notificationSize();
nds.TopLevel = false;
nds.FormBorderStyle = ... // you may want to set this to none
nds.Dock = ... // you may want to set this to fill
f.Controls.Add(nds);
nds.Show(); // Open another form on Modal Dialog
f.ShowDialog(); // Open Modal window
答案 1 :(得分:1)
嗯,我不太明白这个目的是什么,但是这样可以解决问题:
var f = new Form();
f.IsMdiContainer = true;
f.ShowInTaskbar = false;
f.BackColor = Color.Black;
f.Size = this.Size;
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
f.StartPosition = FormStartPosition.CenterParent;
f.Opacity = 0.6;
var nds = new notificationSize();
nds.Show();
nds.MdiParent = f;
f.ShowDialog(); // Open Modal window