开发者

c# winforms Child form load problem

开发者 https://www.devze.com 2022-12-12 11:45 出处:网络
I have a dialog-based application. I need to show a child window like this: (1) First, the application\'s main dialog window will show up,

I have a dialog-based application.

I need to show a child window like this:

(1) First, the application's main dialog window will show up,

(2) then, a child dialog window will show up automatically on top of that.

You know, it is not enough to call the child window's ShowDialog() in the paren开发者_如何学编程t window's constructor or load event. Coz in those cases, the child window will appear first.

What should I do to achieve that?


Use can use the event Shown of your main dialog, to show the child in front of you main dialog. This event is only raised once, when the main dialog is shown the first time. Also you should use the Show() (not ShowDialog) method and then call BringToFront() of your child dialog.

private void OnShown(EventArgs e) {
  ChildDialog child = new ChildDialog();
  child.Show(this);
  child.BringToFront();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消