C# Transparent Menu

How To Make a Transparent Menu Using C#

Transparent Menu In C#


In a Previous C# Tutorial We Did a Transparent Button and in This One We Will See How To Make a Transparent Horizontal Menu Using Panel and Buttons in C# Windows Form Application Using 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 Transparent_Menu : Form
    {
        public Transparent_Menu()
        {
            InitializeComponent();
        }

        private void Transparent_Menu_Load(object sender, EventArgs e)
        {

           // set the panel that contains the buttons to transparent
            panel1.BackColor = Color.FromArgb(70, 0, 0, 0);

            // you can use this code for each buttons
            // or use the foreach loop

            // foreach control in the panel
            foreach (Control control in panel1.Controls)
            {
                // check if the control is a button
                if(control is Button)
                {
                    // convert the control to a button
                    Button btn = (Button) control;

                    // set the button style to flat
                    btn.FlatStyle = FlatStyle.Flat;

                    // set the background color for the button
                    btn.BackColor = Color.FromArgb(120, 0, 0, 0);

                    //button1.FlatAppearance.BorderColor = Color.FromArgb(200,255,255,255);

                    // set the border size
                    btn.FlatAppearance.BorderSize = 0;

                    // set a new background color on mouse over
                    btn.FlatAppearance.MouseOverBackColor = Color.FromArgb(140, 155, 89, 182);

                    // set a new background color on mouse down
                    btn.FlatAppearance.MouseDownBackColor = Color.FromArgb(180, 39, 174, 96);

                    // set button forColor
                    btn.ForeColor = Color.White;

                    // set the font size
                    btn.Font = new Font(btn.Font.FontFamily, 22);

                    // set the cursor to hand
                    btn.Cursor = Cursors.Hand;
                }
            }
        }
    }
}



OUTPUT:


How To Create a Transparent Menu In C#




Share this

Related Posts

Previous
Next Post »