ContextMenuStrip简单使用

 

(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);

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章