C#中的Toggable Topmost按钮 [英] Toggable Topmost button in C#

查看:128
本文介绍了C#中的Toggable Topmost按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何制作一个可切换的按钮,使用户界面中最顶级的应用程序?我正在尝试创建一个应用程序,并希望能够选择使其成为最顶层的应用程序。

解决方案

您好,



 以下帮助仅适用于Windows窗体项目构建。


 


  1。将Button对象拖到表单上。


  2。进行您喜欢的颜色,文字字体等视觉变化。


  3。将Button.Text更改为与其功能相关的内容。


  4。将您的按钮订阅到事件Mouse_Click处理程序。


  5。在Button事件处理程序中使用以下代码括号;

 

private void button1_MouseClick(object sender,MouseEventArgs e)
{{/ p >

this.TopMost ^ = true;

}

  6。编译并执行项目以查看是否按预期工作。


 


 我提供的代码,应该在每次鼠标点击事件中,


切换Forms属性TopMost的状态。 但是,


是一些会覆盖TopMost的对象,例如Dialogs。


即使Dialog丢失了Focus,也可以保持TopMost,直到关闭。



 希望这会有所帮助:)


How could I make a toggleable button to make the UI top most applications in c#? I am trying to make an application and want to have the option to make it topmost applications.

解决方案

Hello,

 The following assistance only applies to Windows Forms project builds.

 

 1. Drag a Button object onto your Form.

 2. Make visual changes that your prefer, color, text font, etc.

 3. Change Button.Text to something relative to its function.

 4. Subscribe your Button to Event Mouse_Click handler.

 5. Use the following code, inside the Button event handler, brackets;

private void button1_MouseClick( object sender, MouseEventArgs e )
{

this.TopMost ^= true;

}

 6. Compile and execute the project to see if works as expected.

 

 The code that I have provided, should on every Mouse Click event,

toggle the state of the Forms property TopMost.  However, there

are some objects that will override TopMost such as Dialogs.

Even when Dialog has lost Focus, can remain TopMost, until closed.

 Hope this helps :)


这篇关于C#中的Toggable Topmost按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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