本文整理汇总了C#中System.Windows.Forms.ContextMenu.Show方法的典型用法代码示例。如果您正苦于以下问题:C# ContextMenu.Show方法的具体用法?C# ContextMenu.Show怎么用?C# ContextMenu.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.Show方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShowContextMenu
public override void ShowContextMenu(CommandID menuID, int x, int y)
{
base.ShowContextMenu(menuID, x, y);
if (menuID == WorkflowMenuCommands.SelectionMenu)
{
ContextMenu contextMenu = new ContextMenu();
foreach (DesignerVerb verb in Verbs)
{
MenuItem menuItem = new MenuItem(verb.Text, new EventHandler(OnMenuClicked));
menuItem.Tag = verb;
contextMenu.MenuItems.Add(menuItem);
}
foreach (MenuItem menu in BuildItemsForSeletion())
{
contextMenu.MenuItems.Add(menu);
}
WorkflowView workflowView = GetService(typeof(WorkflowView)) as WorkflowView;
if (workflowView != null)
{
contextMenu.Show(workflowView, workflowView.PointToClient(new Point(x, y)));
}
}
}
示例2: changeTeamButton_Click
private void changeTeamButton_Click(object sender, EventArgs e)
{
ContextMenu menu = new ContextMenu();
if (Program.TasClient.MyBattle != null)
{
menu.MenuItems.AddRange(ZeroKLobby.MicroLobby.ContextMenus.GetSetAllyItems());
}
menu.Show(btnChangeTeam, new Point(0, 0));
}
示例3: Contmenus
public void Contmenus()
{
MenuItem m1 = new MenuItem("添加");
MenuItem m2 = new MenuItem("修改");
MenuItem[] menuitems = new MenuItem[] { m1, m2 };
ContextMenu button1ctm = new ContextMenu(menuitems);
Point p = new Point(0, button3.Size.Height);
button1ctm.Show(button3,p);
m1.Click += new System.EventHandler(tianj_click);//选择添加按钮时,添加事件
m2.Click += new System.EventHandler(tianj1_click);//同上,选择修改按钮
}
示例4: propertyGrid1_MouseClick
private void propertyGrid1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var selectedObj = propertyGrid1.SelectedGridItem;
var mainFrm = Application.OpenForms.OfType<MainForm>().FirstOrDefault();
var contextMenu = new ContextMenu(mainFrm.GetMenuItems(selectedObj.Value.GetType()));
contextMenu.Show(sender as Control, e.Location);
}
}
示例5: addAIButton_Click
private void addAIButton_Click(object sender, EventArgs e)
{
var enabled = Program.TasClient.MyBattle != null; // && Program.ModStore.Ais != null && Program.ModStore.Ais.Any();
ContextMenu menu = new ContextMenu();
if (!enabled)
{
// TODO
return;
}
menu.MenuItems.AddRange(ZeroKLobby.MicroLobby.ContextMenus.GetAddBotItems());
menu.Show(btnAddAI, new Point(0, 0));
}
示例6: bookGridView_MouseClick
private void bookGridView_MouseClick(Object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
MenuItem miEdit = new MenuItem("Edit");
MenuItem miDelete = new MenuItem("Delete");
MenuItem miAdd = new MenuItem("Add");
m.MenuItems.Add(miDelete);
m.MenuItems.Add(miAdd);
m.MenuItems.Add(miEdit);
miEdit.Click += new System.EventHandler(this.editMenuItem_Click);
miAdd.Click += new System.EventHandler(this.addMenuItem_Click);
miDelete.Click += new System.EventHandler(this.deleteMenuItem_Click);
int currentMouseOverRow = bookGridView.HitTest(e.X, e.Y).RowIndex;
m.Show(bookGridView,new Point(e.X,e.Y));
}
}
示例7: SzBox_MouseDown
private void SzBox_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
int indexOfItem;
indexOfItem = SzBox.IndexFromPoint(e.X, e.Y); //(2)
if (indexOfItem < SzBox.Items.Count)
{
SuppressChange = true;
SzBox.SelectedIndex = indexOfItem;
MenuItem[] Y = new MenuItem[2];
Y[0] = new MenuItem("Delete Seizure");
Y[0].Click += new System.EventHandler(DeleteSz);
Y[1] = new MenuItem("Edit Notes");
ContextMenu X = new ContextMenu(Y);
X.Show(SzBox, new Point(e.X, e.Y));
}
}
}
示例8: dataGridViewAlunos_MouseClick
private void dataGridViewAlunos_MouseClick(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
m.MenuItems.Add(new MenuItem("Ver"));
m.MenuItems.Add(new MenuItem("Copiar"));
/*int currentMouseOverRow = dataGridViewAlunos.HitTest(e.X, e.Y).RowIndex;
if (currentMouseOverRow >= 0)
{
m.MenuItems.Add(new MenuItem(string.Format("Do something to row {0}", currentMouseOverRow.ToString())));
}*/
m.Show(dataGridViewAlunos, new Point(e.X, e.Y));
}
}
示例9: mModelTree_MouseUp
private void mModelTree_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var treeNode = tvwModel.GetNodeAt(e.X, e.Y);
if (treeNode != null)
{
var controller = ((ModelObjectTreeNode)treeNode).Controller;
var cm = new ContextMenu();
var commands = controller.GetMenuCommands();
if (commands != null)
{
foreach (var tmpMenuCommand in controller.GetMenuCommands())
{
cm.MenuItems.Add(tmpMenuCommand);
}
}
cm.Show(this, new Point(e.X, e.Y));
}
}
}
示例10: DGVProperties_MouseClick
private void DGVProperties_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenu m = new ContextMenu();
m.MenuItems.Add(new MenuItem("Cut"));
m.MenuItems.Add(new MenuItem("Copy"));
m.MenuItems.Add(new MenuItem("Paste"));
m.MenuItems[0].Click += DGVProperties_Cut;
int currentMouseOverRow = DGVProperties.HitTest(e.X, e.Y).RowIndex;
if (currentMouseOverRow >= 0)
{
m.MenuItems.Add(new MenuItem(string.Format("Do something to row {0}", currentMouseOverRow.ToString())));
}
m.Show(DGVProperties, new Point(e.X, e.Y));
}
}
示例11: Click
public void Click(ScreenDrawingSurface surface, Point location)
{
ContextMenu menu = new ContextMenu();
// find a join to modify
var nearest = NearestJoin(surface, location);
if (nearest != null)
{
string typeText = (nearest.type == JoinType.Vertical)? "Left-Right" : "Up-Down";
menu.MenuItems.Add("Modify " + typeText + " Join from " + nearest.screenOne + " to " + nearest.screenTwo, (s, e) => EditJoin(surface, nearest));
menu.MenuItems.Add("Delete " + typeText + " Join from " + nearest.screenOne + " to " + nearest.screenTwo, (s, e) => DeleteJoin(surface, nearest));
}
else
{
if (location.X > surface.Width - surface.Screen.Tileset.TileSize)
{
menu.MenuItems.Add(new MenuItem("New Rightward Join from " + surface.Screen.Name,
(s, e) => NewJoin(surface, surface.Screen.Name, "", JoinType.Vertical, location.Y / surface.Screen.Tileset.TileSize)));
}
if (location.X < surface.Screen.Tileset.TileSize)
{
menu.MenuItems.Add(new MenuItem("New Leftward Join from " + surface.Screen.Name,
(s, e) => NewJoin(surface, "", surface.Screen.Name, JoinType.Vertical, location.Y / surface.Screen.Tileset.TileSize)));
}
if (location.Y > surface.Height - surface.Screen.Tileset.TileSize)
{
menu.MenuItems.Add(new MenuItem("New Downward Join from " + surface.Screen.Name,
(s, e) => NewJoin(surface, surface.Screen.Name, "", JoinType.Horizontal, location.X / surface.Screen.Tileset.TileSize)));
}
if (location.Y < surface.Screen.Tileset.TileSize)
{
menu.MenuItems.Add(new MenuItem("New Upward Join from " + surface.Screen.Name,
(s, e) => NewJoin(surface, "", surface.Screen.Name, JoinType.Horizontal, location.X / surface.Screen.Tileset.TileSize)));
}
}
menu.Show(surface, location);
}
示例12: dataGridView1_CellMouseClick
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button != MouseButtons.Right)
return;
if (e.RowIndex < 0 || e.ColumnIndex < 0)
return;
var row = dataGridView1.Rows[e.RowIndex].DataBoundItem as BreakPointEntry;
breakPointEntry = row;
var relativeMousePosition = dataGridView1.PointToClient(Cursor.Position);
MenuItem menu = new MenuItem(row.Name);
menu.Enabled = false;
ContextMenu m = new ContextMenu();
m.MenuItems.Add(menu);
m.MenuItems.Add(new MenuItem("Copy to &Clipboard", new EventHandler(MenuItem3_Click)));
m.MenuItems.Add(new MenuItem("&Delete breakpoint", new EventHandler(MenuItem1_Click)));
m.Show(dataGridView1, relativeMousePosition);
}
示例13: CheckSuitsGrid_MouseClick
private void CheckSuitsGrid_MouseClick(object sender, MouseEventArgs e)
{
switch (e.Button)
{
case MouseButtons.Right:
ContextMenu contextMenu = new ContextMenu();
MenuItem menuItemEdit = new MenuItem("&Edit", MenuItemEdit_Click);
MenuItem menuItemDelete = new MenuItem("&Delete", MenuItemDelete_Click);
var hti = checkSuitsGrid.HitTest(e.X, e.Y);
if (hti.RowIndex >= 0)
{
checkSuitsGrid.ClearSelection();
checkSuitsGrid.Rows[hti.RowIndex].Selected = true;
}
contextMenu.MenuItems.Add(menuItemEdit);
contextMenu.MenuItems.Add(menuItemDelete);
checkSuitsGrid.ContextMenu = contextMenu;
contextMenu.Show(checkSuitsGrid, new Point(e.X, e.Y));
break;
}
}
示例14: OnMouseClick
//컨텍스트 메뉴(context menu)
// 마우스 우측 버튼이 눌린 경우 실행되는 Form 재정의 메서드
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
// 마우스 우측 버튼이 눌린 경우
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
// 컨텍스트 메뉴 객체를 만들고
ContextMenu ctxMenu = new ContextMenu();
// 컨텍스트 메뉴에 들어갈 2개의 MenuItem을 생성해서 추가
MenuItem menuItem = new MenuItem("새로 고침");
menuItem.Click += msRefresh_Click;
ctxMenu.MenuItems.Add(menuItem);
menuItem = new MenuItem("종료");
//해당 메뉴에 이벤트 처리기 연결
menuItem.Click += msClose_Click;
ctxMenu.MenuItems.Add(menuItem);
// 최종적으로 구성된 컨텍스트 메뉴를 마우스가 눌린 위치에서 팝업
ctxMenu.Show(this, e.Location);
}
}
示例15: OnMouseUp
protected override void OnMouseUp(MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
cm = new ContextMenu();
cm.MenuItems.AddRange(new MenuItem[]{
new MenuItem("Add", new EventHandler(addOnClick)),
new MenuItem("Rename", new EventHandler(renameOnClick)),
new MenuItem("Delete", new EventHandler(deleteOnClick))
});
for (int i = 0; i < TabCount; i++)
{
Rectangle r = GetTabRect(i);
if (r.Contains(e.Location))
{
cm.Tag = i;
break;
}
}
cm.Show(this, e.Location);
}
base.OnMouseUp(e);
}