Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个将标签添加到 MenuStrip 的函数。在 ItemClicked 函数上,我使用了以下代码:
MenuItem mi = sender as MenuItem; string a = mi.Text;
但是,在阅读此内容后,我收到以下错误:
Object reference not set to an instance of an object.
private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { string str=e.ClickedItem.Text; }