C# Design Form Using Panels

How To Design a Form With Panels In C#

Design Form With Panels In C#



In Another C# Design Tutorial We Did a Nice Looking Login Form Design .
And In this C# Tutorial we will see How To Create a Simple Form Design Using Panels and Labels Controls In C# And Visual Studio Editor .



WATCH THIS C# TUTORIAL


Project Source Code:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Csharp_Tutorials
{
    public partial class Design_Form_Using_Panels : Form
    {
        public Design_Form_Using_Panels()
        {
            InitializeComponent();
        }


        // create color vars
        Color p1_color;
        Color p2_color;
        Color p3_color;

        private void Design_Form_Using_Panels_Load(object sender, EventArgs e)
        {

           // get the panels color
            p1_color = panel1.BackColor;
            p2_color = panel2.BackColor;
            p3_color = panel3.BackColor;

        }

        private void label1_MouseEnter(object sender, EventArgs e)
        {
            // set the panel color to white
            panel1.BackColor = Color.White;

            // set the label forcolor to the panel color
            label1.ForeColor = p1_color;
        }

        private void label1_MouseLeave(object sender, EventArgs e)
        {
            panel1.BackColor = p1_color;
            label1.ForeColor = Color.White;
        }

//******* We Will Do The Same For The Other Elements *******//

        private void label2_MouseEnter(object sender, EventArgs e)
        {
            panel2.BackColor = Color.White;
            label2.ForeColor = p2_color;
        }

        private void label2_MouseLeave(object sender, EventArgs e)
        {
            panel2.BackColor = p2_color;
            label2.ForeColor = Color.White;
        }

        private void label3_MouseEnter(object sender, EventArgs e)
        {
            panel3.BackColor = Color.White;
            label3.ForeColor = p3_color;
        }

        private void label3_MouseLeave(object sender, EventArgs e)
        {
            panel3.BackColor = p3_color;
            label3.ForeColor = Color.White;
        }


    }
}



OUTPUT:


How To Design a Form With Panels Using C#




Share this

Related Posts

Previous
Next Post »