radContextMenu + NotifyIcon

3 posts, 1 answers
  1. Helen
    Helen avatar
    101 posts
    Member since:
    Nov 2008

    Posted 09 Oct 2012 Link to this post

    Is there any way to use a radContextMenu with the WinForms NotifyIcon? I'd like to use the radMenus for my WinForms app, but I need the NotifyIcon functionality, and I can't see how to use rad Menus with it.

    Thanks,

    Helen
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 12 Oct 2012 Link to this post

    Hello Helen,

    Thank you for writing.

    Here is how to incorporate RadContextMenu with NotifyIcon:
    public partial class Form1 : Form
       {
           RadContextMenu contextMenu = new RadContextMenu();
            
           public Form1()
           {
     
               InitializeComponent();
     
               this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
               notifyIcon1.Icon = new Icon(@"C:\Program Files (x86)\Telerik\RadControls for WinForms Q2 2012 SP2\Examples\QuickStart\Resources\telerik.ico");
               notifyIcon1.Text = "Form1 (NotifyIcon example)";
               notifyIcon1.Visible = true;
               notifyIcon1.MouseDown += new MouseEventHandler(notifyIcon1_MouseDown);
     
               contextMenu.Items.Add(new RadMenuHeaderItem("Hello, I am RadContextMenu"));
               RadMenuItem item = new RadMenuItem("Close");
               item.Click += new EventHandler(item_Click);
               contextMenu.Items.Add(item);
           }
     
           void item_Click(object sender, EventArgs e)
           {
               this.Close();
           }
     
           void notifyIcon1_MouseDown(object sender, MouseEventArgs e)
           {
               if (e.Button == System.Windows.Forms.MouseButtons.Right)
               {
                   contextMenu.Show(MousePosition);
               }
           }
       }

    I hope that the provided information addresses your questions. Should you have any further questions, do not hesitate to contact me.
     
    Greetings,
    Stefan
    the Telerik team
    You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Helen
    Helen avatar
    101 posts
    Member since:
    Nov 2008

    Posted 12 Oct 2012 Link to this post

    This is cool -- thank you!

    Now I can use your theming for all my controls.

    Best

    Helen
Back to Top