![](/img/trans.png)
[英]How prevent to create a .exe.config in a Windows Forms Application build (Visual Studio Community 2019 - C#)
[英]How to code Menues / Sub Menues in .Net Core Windows Forms Application in Visual Studio 2019 C#
我正在使用 Visual Studio 2019 並在 .Net Core 5.0 中制作 Windows 應用程序,但我堅持了一點,即如何編寫菜單和子菜單(下拉菜單),因為 .Net Core 不提供像 .Net 4 那樣易於訪問(在開發時鼠標懸停可以看到子菜單和 Dbl+單擊它)。 請給我正確的編碼菜單/子菜單的方法。
您可能需要手動執行此操作。
public partial class Form1 : Form
{
public Form1()
{
// Added Menustrip (id 'menuStrip1') with one item (fileToolStripMenuItem1) from UI and
InitializeComponent();
ConstructMenu();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void ConstructMenu()
{
// Define new toolstrip item
ToolStripMenuItem openFileToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
openFileToolStripMenuItem1.Name = "OpenfileToolStripMenuItem1";
openFileToolStripMenuItem1.Size = new System.Drawing.Size(37, 20);
openFileToolStripMenuItem1.Text = "&Open File";
// event
openFileToolStripMenuItem1.Click += OpenFileToolStripMenuItem1_Click;
// Add it to parent toolstrip item
fileToolStripMenuItem1.DropDownItems.Add(openFileToolStripMenuItem1);
}
private void OpenFileToolStripMenuItem1_Click(object sender, EventArgs e)
{
// ImplementedException;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.