求救啊!!!
现在做了一个ContextMenu:
rightkeyMenu请问该如何写?

解决方案 »

  1.   

    思路,我没有解决:
    左边是一个隐含的pancel
      

  2.   

    差不多控件都有一个ContextMenu属性,把该属性设置为你自己建的rightkeyMenu
      

  3.   

    我也在等待。用iconnotiy只能实现右键,不知道有没有其他办法。。
      

  4.   

    刚做了一个Asp.net 2.0 的自定义控件:http://blog.csdn.net/ChengKing/archive/2007/03/31/1547692.aspx
      

  5.   

    终于解决:可以单独写成一个方法,自己可以试试。
    Imports System.Reflection
    Public Class Form1
        Private Sub NotifyIcon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
            If e.Button = Windows.Forms.MouseButtons.Left Then
                NotifyIcon1.ContextMenuStrip = ContextMenuStrip1
                Dim eventSource As NotifyIcon = Nothing
                Dim niHandle As Type = Nothing
                eventSource = CType(sender, NotifyIcon)
                niHandle = eventSource.GetType            niHandle.InvokeMember("ShowContextMenu", BindingFlags.Instance Or BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.InvokeMethod, Nothing, eventSource, Nothing)
            Else
                NotifyIcon1.ContextMenuStrip = ContextMenuStrip2
                Dim eventSource As NotifyIcon = Nothing
                Dim niHandle As Type = Nothing
                eventSource = CType(sender, NotifyIcon)
                niHandle = eventSource.GetType            niHandle.InvokeMember("ShowContextMenu", BindingFlags.Instance Or BindingFlags.Instance Or BindingFlags.NonPublic Or BindingFlags.InvokeMethod, Nothing, eventSource, Nothing)
            End If
        End Sub
    C#方案(要简单调整一下,对着VB就知道了):
    using   System.Reflection;     
        
      可以在NotifyIcon的Click事件中加入以下代码来实现:     
      private   void   notifyIcon1_Click(object   sender,   System.EventArgs   e)     
      {     
      NotifyIcon   eventSource   =   null;     
      Type   niHandle   =   null;     
      eventSource   =   (NotifyIcon)sender;     
      niHandle   =   eventSource.GetType();     
                                                Invoke   the   private   ShowContextMenu   method.     
      niHandle.InvokeMember(     
      "ShowContextMenu",     
      BindingFlags.Instance   |     
      BindingFlags.NonPublic   |     
      BindingFlags.InvokeMethod,     
      null,     
      eventSource,     
      null     
      );     
      }