Advertisement
ThinkTwiceModz

Form Stays On Top

Jul 22nd, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp7
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void button1_Click(object sender, EventArgs e)
  21.         {
  22.             if (button1.Text == "False")
  23.             {
  24.                 this.TopMost = true;
  25.                 button1.Text = "True";
  26.             }
  27.             else
  28.             if (button1.Text == "True")
  29.             {
  30.                 this.TopMost = false;
  31.                 button1.Text = "False";
  32.             }
  33.         }
  34.  
  35.         private void checkBox1_CheckedChanged(object sender, EventArgs e)
  36.         {
  37.             if (checkBox1.Checked)
  38.             {
  39.                 if (checkBox1.Text == "False")
  40.                 {
  41.                     this.TopMost = true;
  42.                     checkBox1.Text = "True";
  43.                 }
  44.             }
  45.             else
  46.             {
  47.                 this.TopMost = false;
  48.                 checkBox1.Text = "False";
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement