无法将lambda表达式转换为类型“System.Delegate”

    

            this.Invokes(() =>

            {

                Environ.Tip = msg;

                int index = dgv.FindIndex("ShuJuBM", ShuJuBM);

                dgv.set_Text(dgv.Rows[index], "state", "成功");

                dgv.set_Text(dgv.Rows[index], "msg", msg);

            });

 

上面的用匿名类型会出错,改为下面的写法就ok啦。

       

 

 

 

//this.Invokes((Action)(() =>

            //{

            //    Environ.Tip = msg;

            //    int index = dgv.FindIndex("ShuJuBM", ShuJuBM);

            //    dgv.set_Text(dgv.Rows[index], "state", "成功");

            //    dgv.set_Text(dgv.Rows[index], "msg", msg);

            //}));

 

            this.Invokes(new MethodInvoker(() =>

            {

                Environ.Tip = msg;

                int index = dgv.FindIndex("ShuJuBM", ShuJuBM);

                dgv.set_Text(dgv.Rows[index], "state", "成功");

                dgv.set_Text(dgv.Rows[index], "msg", msg);

            }));

posted on 2012-11-16 17:36  ewyb  阅读(2349)  评论(1编辑  收藏  举报

导航