我想使用 C# 创建一个上下文菜单,该菜单将显示在节点旁边,类似于在 Visual Studio 中发生的情况:
我现在拥有的代码导致主窗体闪烁。
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;
}
}
}