已有56人关注
未将对象引用设置到对象的实例。
发表在C#图书答疑 2015-03-11
是否精华
版块置顶:
用户代码未处理 System.NullReferenceException
  Message=未将对象引用设置到对象的实例。
  Source=MonitorClient
  StackTrace:
       在 SuperSight.NSClient.NSMultiPlay.PlayWindow.FindButton(String tag) 位置 C:\Users\Administrator\Desktop\MonitorClient代码 - 副本\SuperSight\NSClient\NSMultiPlay\PlayWindow.cs:行号 630
       在 SuperSight.NSClient.NSMultiPlay.PlayWindow.<>c__DisplayClass51.<set_MicButtonState>b__50() 位置 C:\Users\Administrator\Desktop\MonitorClient代码 - 副本\SuperSight\NSClient\NSMultiPlay\PlayWindow.cs:行号 3259
       在 System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       在 System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       在 System.Threading.ExecutionContext.runTryCode(Object userData)
       在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       在 System.Windows.Forms.Control.InvokeMarshaledCallbacks()
  InnerException: 
分享到:
精彩评论 1
小科_mrkj
学分:43 LV2
2015-03-12
沙发
读者朋友:
    您好,代码修改如下:
private ToolStripItem FindButton(string tag)
        {
            ToolStripItem i=null;
            foreach(ToolStripItem item in toolStrip1.Items)
            {
                if (item.Tag.Equals(tag))
                {
                    i=item;
                }
            }
            return i;
        }
调用代码如下:
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(FindButton("0").Text);
        }
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照