C# Exercises

Home AgriMetSoft About Contact

Nice Menu and Form in C# | Visual Studio

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

namespace Nice_Menu_in_Winforms
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    }

    private void label1_Click(object sender, EventArgs e)
    {
      this.Close();
    }
    public const int WM_NCLBUTTONDOWN = 0xA1;
    public const int HT_CAPTION = 0x2;
    [DllImportAttribute("user32.dll")]
    public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
    private void panel1_MouseMove(object sender, MouseEventArgs e)
    {
      if (e.Button == MouseButtons.Left)
      {
        Point loc1 = MousePosition;
        this.Location = loc1;
      }
    }

    private void panel3_Click(object sender, EventArgs e)
    {
      panel3.BorderStyle = BorderStyle.Fixed3D;
      panel4.BorderStyle = BorderStyle.None;
      Home h = new Home();
      h.TopLevel = false;
      if (panel5.Controls.Count > 0)
        panel5.Controls.Clear();
      panel5.Controls.Add(h);
      h.BringToFront();
      h.Show();
    }

    private void panel4_Click(object sender, EventArgs e)
    {
      panel3.BorderStyle = BorderStyle.None;
      panel4.BorderStyle = BorderStyle.Fixed3D;
      Edit edt = new Edit();
      edt.TopLevel = false;
      if (panel5.Controls.Count > 0)
        panel5.Controls.Clear();
      panel5.Controls.Add(edt);
      edt.BringToFront();
      edt.Show();
    }
   
  }
}

		
	 


Download the project of Visual Studio 2013 in DropBox Download


How to Make Nice Menu and Form in Winforms C# | Using Panel


List of Exercises