when button clicked
i want when i create the button and click a menu appear in my windows application !! using c#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gopal MahadakPosted Jun 29, 2012, 11:25 PM
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;
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Button myText = new Button();
myText.Location = new Point(25, 35);
myText.Text = "First";
myText.Click += new EventHandler(myText_Click);
this.Controls.Add(myText);
}
private void myText_Click(object sender, EventArgs e)
{
MainMenu mnuFileMenu = new MainMenu();
this.Menu = mnuFileMenu;
MenuItem myMenuItemFile = new MenuItem("&File");
MenuItem m3 = new MenuItem("new");
MenuItem m4 = new MenuItem("open");
mnuFileMenu.MenuItems.Add(myMenuItemFile);
myMenuItemFile.MenuItems.Add(m3);
myMenuItemFile.MenuItems.Add(m4);
}
}
}
younis abdeljawwadPosted Jun 29, 2012, 11:31 AM
Gopal MahadakPosted Jun 29, 2012, 8:48 AM
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;
namespace WindowsFormsApplication10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Button myText = new Button();
myText.Location = new Point(25, 35);
myText.Text = "First";
myText.Click += new EventHandler(myText_Click);
this.Controls.Add(myText);
}
private void myText_Click(object sender, EventArgs e)
{
MainMenu mnuFileMenu = new MainMenu();
this.Menu = mnuFileMenu;
MenuItem myMenuItemFile = new MenuItem("&File");
mnuFileMenu.MenuItems.Add(myMenuItemFile);
}
}
}
younis abdeljawwadPosted Jun 29, 2012, 7:46 AM
Hemant KumarPosted Jun 29, 2012, 7:01 AM
private voi btn_click(object sender,EventArgs e)
{
menu1.Visible=true;
}