本文介绍了如何在C#中创建上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用C#创建一个上下文菜单,该菜单将显示在类似于Visual Studio的节点旁边的节点上。
I want to create a context menu using C# that will display next to the node similar to what happens here in Visual Studio:
我现在使用的代码导致主窗体闪烁。
The code I have now causes the main form to flicker.
private void treeView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var myForm = new Form {Text = "My Form"};
myForm.SetBounds(10, 10, 200, 200);
myForm.Show();
// Determine if the form is modal.
if (myForm.Modal == false)
{
// Change borderstyle and make it not a top level window.
myForm.FormBorderStyle = FormBorderStyle.FixedToolWindow;
myForm.TopLevel = false;
}
}
}
推荐答案
为什么不直接使用 Form.ShowDialog
?
来自:
Form.ShowDialog方法
这篇关于如何在C#中创建上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!