[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1102
  • Last Modified:

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.
0
newbieweb
Asked:
newbieweb
1 Solution
 
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
 
newbiewebAuthor Commented:
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now