C# WinForms: I need to update the text on a ContextMenuStrip

I created a ContextMenuStrip but need to update the item text in code.  I have no problem assigning the next text to the Text property.  The problem I have is getting a handle to the particular menu item.

Can I do this from the ContextMenuStrip to which the item belongs?

How do I do this?

Thanks.
newbiewebSr. Software EngineerAsked:
Who is Participating?
 
käµfm³d 👽Commented:
How are you attempting to get the item? Each item in a CMS is itself an object, so you should just be able to use its name.

e.g.

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.helloWorldToolStripMenuItem.Text = "Goodbye World!";
        }
    }
}

Open in new window


Before and After
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.