How to Hide a WinForm in C#
By FoxLearn 1/9/2025 9:05:22 AM 9.26K
In C#, you can hide a WinForm after it run by using the Hide() method of the form.
What is WinForms in c#?
C# Windows Forms is a GUI framework that allows developers to build desktop applications for the Windows operating system. These applications are developed using the C# programming language in conjunction with the .NET framework.
How to Hide a WinForm in C#?
Open your Visual Studio, then click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "HideApplication" and then click OK
Open your form designer, then add a Form1_Show and Form1_Load event handlers as shown below.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; namespace HideApplication { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Shown(object sender, EventArgs e) { //Hide your windows forms application this.Hide(); } private void Form1_Load(object sender, EventArgs e) { Thread.Sleep(5000);//5s MessageBox.Show("You can't see me !", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
These methods are useful for controlling the visibility of your WinForms in C#.
VIDEO TUTORIAL
- How to Create a custom Progress Bar with Percentage in C#
- How to update UI from another thread in C#
- How to Create a Wait Form Dialog in C#
- How to Get all Forms and Open Form with Form Name in C#
- How to use Advanced Filter DataGridView in C#
- How to Print DataGridView with Header & Footer with Landscape in C#
- How to Add Combobox to DataGridView in C#
- How to zoom an image in C#
Categories
Popular Posts
AdminKit Bootstrap 5 HTML5 UI Kits Template
11/17/2024
Spica Admin Dashboard Template
11/18/2024