现在的位置: 首页 > 综合 > 正文

ContextMenuStrip简单使用

2013年12月04日 ⁄ 综合 ⁄ 共 756字 ⁄ 字号 评论关闭

 

(1)来源

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

 

(2)继承层次

System.Object

  System.MarshalByRefObject
    System.ComponentModel.Component
      System.Windows.Forms.Control
        System.Windows.Forms.ScrollableControl
          System.Windows.Forms.ToolStrip
            System.Windows.Forms.ToolStripDropDown
              System.Windows.Forms.ToolStripDropDownMenu
                System.Windows.Forms.ContextMenuStrip

 

(3)重要成员

.Items :获取属于

ToolStrip
的所有项。

Show(Point) :相对于指定的屏幕位置定位

ToolStripDropDown

 

(4)例子

//在Form_Load响应函数中

contextMenuStrip1.Items.Add("apple");

contextMenuStrip1.Items.Add("banana");

contextMenuStrip1.Items.Add("pear");

//在鼠标按下响应函数中

if (e.Button == MouseButtons.Right)

{

     contextMenuStrip1.Show(Cursor.Position);

}

抱歉!评论已关闭.