SEARCH C# PROGRAMMING CODES HERE

HIDE & SHOW CONTROLS IN C# Vsual studio

HIDE & SHOW CONTROL IN C#
To Hide & show control, here I am using Buttons.
For Example
1-When the user press Button-1 then it will hide
and Button-2 will show 
2-When the user press Button-2 it will Hide and Button-1 will show.
Step - Add two Buttons from the toolbox and add this code.

















CODE
using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
           
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            button2.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            button1.Hide();
            button2.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            button2.Hide();
            button1.Show();
        }
    }
}

No comments:

Post a Comment