this.TopMost = true 不起作用? [英] this.TopMost = true not working?

查看:46
本文介绍了this.TopMost = true 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 C# 非常陌生,并且仍在努力理解它(在一些非常有耐心的朋友的帮助下).

I'm very new to C# and still trying to get my head round it (with help of some very patient friends).

我在将新 Windows 窗体的 TopMost 属性设置为 true 时遇到问题.我有两个(几乎)相同的形式;1 个工作正常,一个没有.

I have an issue with setting a new windows form's TopMost property to true. I have two (almost) identical forms; 1 which works OK and one which doesn't.

两个表单都将 TopMost 属性设置为 true.

Both of the forms have the TopMost property set to true.

  • Form1 显示窗口,当我尝试在它后面单击时,表单闪烁几次并发出窗口哔声.
  • Form2 也显示了表单,但是当我在它后面点击时,表单变灰(或失去焦点),我可以点击主表单.

我已经搜索了这个问题的答案并找到了一个答案,该答案建议将 this.TopMost = true; 放在表单的加载事件中,但没有奏效.

I've searched for an answer to this issue and found an answer which suggested putting this.TopMost = true; in the form's load event but that didn't work.

我更改的唯一可能有影响也可能没有影响的是,Form1 是使用在属性中设置的 .NET 4.5 创建的,在创建 Form2 之前,我将其更改为 .NET 3.5(客户端配置文件).我试过把它改回来,但没有帮助.在我删除并再次创建Form2之前,有人有什么想法吗?

The only thing I have changed which may or may not have had an effect is that Form1 was created with .NET 4.5 set in the properties and before creating Form2, I changed this to .NET 3.5 (client profile). I've tried changing it back but it hasn't helped. Before I delete and create Form2 again, does anyone have any ideas?

非常感谢.(如果您需要更多信息,请告诉我)

Many thanks in advance. (If you need any more information, please just let me know)

推荐答案

TopMost 是一种属性,用于确保一个窗口始终显示在应用程序中的所有其他窗口之上.微软的例子是一个查找和替换工具.

TopMost is a property that is used to make sure one window is always shown above all others within an application. Microsofts example was a find and replace tool.

您发现的不同之处在于 Form1 是通过使用 ShowDialog.显示对话框确保您的表单必须关闭,然后才能再次使用应用程序中的所有其他窗口.例如;使用表单获取用户数据进入父表单数据库.

The difference you are finding is that Form1 was created as a modal dialog through the use of ShowDialog. Show dialog makes sure that your form must be closed before all other windows in the application can be used again. For example; using a form to gain user data to enter into a parent forms database.

Show当您不介意您的用户是否已完成他们的对话时,例如允许您的用户有机会使用某些实用程序(例如计时器、秒表)来协助程序的主要功能.

Show is used when you don't mind if your user has finished with their dialog or not, such as allowing your user the chance to use some utility (e.g timer, stopwatch) that will assist within the main function of a program.

在使用不同的 .Net 框架时,我能想到的唯一视觉差异是不同的 Windows 对话框,例如 OpenFileDialog,已在整个框架中进行了更新

The only visual difference I can think of when using different .Net frameworks, is different windows dialogs such as the OpenFileDialog, that have been updated throughout the framework

这篇关于this.TopMost = true 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆