本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem.Select方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem.Select方法的具体用法?C# ToolStripMenuItem.Select怎么用?C# ToolStripMenuItem.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripMenuItem
的用法示例。
在下文中一共展示了ToolStripMenuItem.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
private void Init()
{
//File menu
var FileOpen = new ToolStripMenuItem("&Open");
FileOpen.Click += FileOpenAction;
var FileClose = new ToolStripMenuItem("&Close");
FileClose.Click += FileCloseAction;
var FileExit = new ToolStripMenuItem("E&xit");
FileExit.Click += FileExitAction;
var file = new ToolStripMenuItem("&File");
file.DropDownItems.AddRange(new ToolStripMenuItem[] {FileOpen,FileClose,FileExit });
//Help Menu
var HelpAbout = new ToolStripMenuItem("&About");
HelpAbout.Click += HelpAboutAction;
var help = new ToolStripMenuItem("&Help");
help.DropDownItems.Add(HelpAbout);
//Seperator
var seperator = new ToolStripSeparator();
//Spinner
SpinnerUi = new NumericUpDown();
SpinnerUi.Minimum = 1;
SpinnerUi.Maximum = decimal.MaxValue;
SpinnerUi.MaximumSize = new System.Drawing.Size(60,int.MaxValue);
SpinnerUi.InterceptArrowKeys = false; //we're doing our own key capture
SpinnerUi.KeyDown += OnSpinnerKeyDown; //keydown repeats if key is being held
SpinnerUi.ValueChanged += OnSpinnerChange;
var spinnerHost = new ToolStripControlHost(SpinnerUi,"Width");
//Multiplier
MultiplierUi = new ToolStripDropDownButton();
MultiplierUi.DropDownItemClicked += OnMultiplierChanged;
ToolStripMenuItem first;
MultiplierUi.DropDownItems.AddRange( new ToolStripItem[] {
first = new ToolStripMenuItem("&1x")
,new ToolStripMenuItem("&2x")
,new ToolStripMenuItem("&4x")
,new ToolStripMenuItem("&8x")
});
first.Select();
OnMultiplierChanged(null,new ToolStripItemClickedEventArgs(first));
//Add everything to the menu
Menu = new MenuStrip();
Menu.Items.AddRange(new ToolStripItem[] { file,help,seperator,MultiplierUi,spinnerHost });
Menu.Dock = DockStyle.Top;
}
示例2: OnMenuItemsLoad
protected virtual void OnMenuItemsLoad(EventArgs e)
{
menu.RightToLeft = this.RightToLeft;
menu.Items.Clear();
List<ToolStripMenuItem> list = new List<ToolStripMenuItem>();
int nr = Items.Count;
for (int i = 0; i < nr; i++)
{
TabControlItem item = this.Items[i];
if (!item.Visible)
continue;
ToolStripMenuItem tItem = new ToolStripMenuItem(item.Title);
tItem.Tag = item;
if (item.Selected)
tItem.Select();
list.Add(tItem);
}
list.Sort(CompareSortText);
menu.Items.AddRange(list.ToArray());
OnMenuItemsLoaded(EventArgs.Empty);
}
示例3: BuildContextMenuStrip
/// <summary>
/// builds the ContextMenuStrip with the clipboard value history and the Control Items
/// </summary>
public void BuildContextMenuStrip()
{
try
{
this.notifyIconMenu.Items.Clear();
ToolStripMenuItem currentItem = null;
List<IType> items = this.GetLastElements(this.settings.MenuItemAmount);
string latestItemKey = "";
if (items.Count > 0)
{
latestItemKey = items.Last().Key;
}
if (this.settings.OrderDesc)
{
items.Reverse();
}
foreach (IType item in items)
{
currentItem = new ToolStripMenuItem(
item.MenuValue,
null,
new EventHandler(Paste_Click),
item.Key
);
this.notifyIconMenu.Items.Add(currentItem);
if (latestItemKey == item.Key)
{
currentItem.Select();
}
}
this.AddControlMenuItems();
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例4: OnMenuItemsLoad
private void OnMenuItemsLoad(EventArgs e)
{
this.Menu.RightToLeft = this.RightToLeft;
this.Menu.Items.Clear();
List<ToolStripMenuItem> list = new List<ToolStripMenuItem>();
for (int i = 0; i < this.Items.Count; i++)
{
TabControlItem item = this.Items[i];
if (!item.Visible)
continue;
ToolStripMenuItem tItem = new ToolStripMenuItem(item.Title);
tItem.Tag = item;
if (item.Selected)
tItem.Select();
list.Add(tItem);
}
// Sort by caption, else do nothing i.e. sorted by call sequence not by caption!!!!!
if (Terminals.Configuration.Files.Main.Settings.Settings.SortTabPagesByCaption)
list.Sort(CompareSortText);
this.Menu.Items.AddRange(list.ToArray());
this.OnMenuItemsLoaded(EventArgs.Empty);
}