本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem.ShowDropDown方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem.ShowDropDown方法的具体用法?C# ToolStripMenuItem.ShowDropDown怎么用?C# ToolStripMenuItem.ShowDropDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripMenuItem
的用法示例。
在下文中一共展示了ToolStripMenuItem.ShowDropDown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecentMenu
//.........这里部分代码省略.........
tsdd.Items.Add(tsmiExplore);
var tsmiCopyFile = new ToolStripMenuItem { Text = "Copy &File" };
var lame = new System.Collections.Specialized.StringCollection();
lame.Add(hf.FullPathWithoutMember);
tsmiCopyFile.Click += (o, ev) => { System.Windows.Forms.Clipboard.SetFileDropList(lame); };
tsdd.Items.Add(tsmiCopyFile);
var tsmiTest = new ToolStripMenuItem { Text = "&Shell Context Menu" };
tsmiTest.Click += (o, ev) => {
var si = new GongSolutions.Shell.ShellItem(hf.FullPathWithoutMember);
var scm = new GongSolutions.Shell.ShellContextMenu(si);
var tsddi = o as ToolStripDropDownItem;
tsddi.Owner.Update();
scm.ShowContextMenu(tsddi.Owner, new System.Drawing.Point(0, 0));
};
tsdd.Items.Add(tsmiTest);
tsdd.Items.Add(new ToolStripSeparator());
}
else
{
//make a menuitem to show the last modified timestamp
var tsmiMissingFile = new ToolStripLabel { Text = "-Missing-" };
tsdd.Items.Add(tsmiMissingFile);
tsdd.Items.Add(new ToolStripSeparator());
}
//in either case, make a menuitem to let you remove the path
var tsmiRemovePath = new ToolStripMenuItem { Text = "&Remove" };
tsmiRemovePath.Click += (o, ev) => { recent.Remove(temp); };
tsdd.Items.Add(tsmiRemovePath);
////experiment of popping open a submenu. doesnt work well.
//item.MouseDown += (o, mev) =>
//{
// if (mev.Button != MouseButtons.Right) return;
// //location of the menu containing this item that was just rightclicked
// var pos = item.Owner.Bounds.Location;
// //the offset within that menu of this item
// var tsddi = item as ToolStripDropDownItem;
// pos.Offset(tsddi.Bounds.Location);
// //the offset of the click
// pos.Offset(mev.Location);
// //tsdd.OwnerItem = item; //has interesting promise, but breaks things otherwise
// tsdd.Show(pos);
//};
//just add it to the submenu for now
item.MouseDown += (o, mev) =>
{
if (mev.Button != MouseButtons.Right) return;
if (item.DropDown != null)
item.DropDown = tsdd;
item.ShowDropDown();
};
}
}
items.Add(new ToolStripSeparator());
var clearitem = new ToolStripMenuItem { Text = "&Clear", Enabled = !recent.Frozen };
clearitem.Click += (o, ev) => recent.Clear();
items.Add(clearitem);
var freezeitem = new ToolStripMenuItem { Text = recent.Frozen ? "&Unfreeze" : "&Freeze" };
freezeitem.Click += (o, ev) => recent.Frozen ^= true;
items.Add(freezeitem);
if (autoload)
{
var auto = new ToolStripMenuItem { Text = "&Autoload", Checked = recent.AutoLoad };
auto.Click += (o, ev) => recent.ToggleAutoLoad();
items.Add(auto);
}
var settingsitem = new ToolStripMenuItem { Text = "&Recent Settings..." };
settingsitem.Click += (o, ev) =>
{
using (var prompt = new InputPrompt
{
TextInputType = InputPrompt.InputType.Unsigned,
Message = "Number of recent files to track",
InitialValue = recent.MAX_RECENT_FILES.ToString()
})
{
var result = prompt.ShowDialog();
if (result == DialogResult.OK)
{
int val = int.Parse(prompt.PromptText);
if (val > 0)
recent.MAX_RECENT_FILES = val;
}
}
};
items.Add(settingsitem);
return items.ToArray();
}