gpt4 book ai didi

c# - 设置存在于 ClassLibrary c# 中的 Windows 窗体的所有者

转载 作者:行者123 更新时间:2023-11-30 21:39:29 25 4
gpt4 key购买 nike

我的 ClassLibrary 有一个名为 LookUpBoxWindows 窗体。我想从我的应用程序调用 LookUpBox 并将我的应用程序设置为它的所有者,然后按以下方式进行操作:

LookUpBox foo = new LookUpBox();
foo.Owner = this;
foo.ShowDialog();

但是当运行我的应用程序并按 Alt+Enter 时,我看到 2 种形式:

Alt_Enter Window

我排除了 foo 的一组 Owner,我看到带有 Alt+Enter 的单个窗口。有人知道如何解决这个问题吗?提前致谢

最佳答案

Window.Owner状态:

When you open a child window by calling ShowDialog, you should also set the Owner property of the child window. If you don't, then your users won't be able to restore both child window and parent window by pressing the task bar button. Instead, pressing the task bar button will yield a list of windows, including both child and parent window, for them to select; only the selected window is restored.

Form.Owner状态:

When a form is owned by another form, it is closed or hidden with the owner form. For example, consider a form named Form2 that is owned by a form named Form1. If Form1 is closed or minimized, Form2 is also closed or hidden.Owned forms are also never displayed behind their owner form. You can use owned forms for windows such as find and replace windows, which should not disappear when the owner form is selected. To determine the forms that are owned by a parent form, use the OwnedForms property.

所以您需要做的是显式设置 foo.ShowInTaskbar = False 以使其在任务栏中隐藏

关于c# - 设置存在于 ClassLibrary c# 中的 Windows 窗体的所有者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45232462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com