none
Toggable Topmost button in C# RRS feed

  • السؤال

  • 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.
    • تم النقل بواسطة CoolDadTx 27/ذو القعدة/1439 01:48 م Winforms related
    26/ذو القعدة/1439 06:15 م

جميع الردود

  • 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 :)

    27/ذو القعدة/1439 02:09 ص
  • can you help me with this but with flatButton2? I broke my project..
    10/ربيع الأول/1441 01:27 ص