开发者

WinForms - Show dialog and still use the calling form

开发者 https://www.devze.com 2023-01-23 10:45 出处:网络
I hav开发者_运维百科e a requirement where the user wants to be able to click a button to show a dialog with some information. They want the ability to move the dialog off of the form and put focus bac

I hav开发者_运维百科e a requirement where the user wants to be able to click a button to show a dialog with some information. They want the ability to move the dialog off of the form and put focus back on the calling form and make changes to the calling form with the dialog still open.

It is basically a map on the main form and the dialog is a map legend.

Is this possible? How would I accomplish this task? It seems like I would need to do something with a panel like how Visual Studio does this with their dockable panels.


Call the Show method instead of ShowDialog.

This method is a non-blocking call (unlike ShowDialog, it will return immediately, not after the new form closes) and will not show the form modally.
You'll probably want to pass the parent form as the parameter so that it will show as a child form.


You can show the dialog in non-modal way.

Like this:

formLegend.Show();


Insead of calling legendForm.ShowDialog(), just use legendForm.Show(). It will display the legend form without restricting the map's usage.

0

精彩评论

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

关注公众号