This is a migrated thread and some comments may be shown as answers.

radContextMenu + NotifyIcon

2 Answers 383 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Helen
Top achievements
Rank 2
Helen asked on 09 Oct 2012, 10:26 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 12 Oct 2012, 08:51 AM
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.
0
Helen
Top achievements
Rank 2
answered on 12 Oct 2012, 05:23 PM
This is cool -- thank you!

Now I can use your theming for all my controls.

Best

Helen
Tags
ContextMenu
Asked by
Helen
Top achievements
Rank 2
Answers by
Stefan
Telerik team
Helen
Top achievements
Rank 2
Share this question
or