Вопрос

I have a function which adds Labels to a MenuStrip. On the ItemClicked function, I was using the following code:

MenuItem mi = sender as MenuItem;
string a = mi.Text;

However, I get the following error, upon reading this:

Object reference not set to an instance of an object.
Это было полезно?

Решение

 private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

         string str=e.ClickedItem.Text;
        }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top