本文介绍了如何在c#winForm中使用Location定义声明字符串变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  string  labelName =   lblCity; 





lblAmtInWords 是标签名称我在标签属性中给出了..



 lblAmtInWords.Location =  new  Point(lblAmtInWords.Location.X, 238 ); 
lblAmtInWords.Location = new Point(lblAmtInWords.Location.Y, 684 );



i希望传递 lblCity 而不是 lblAmtInWords



 lblCity.Location =  new  Point(Convert.ToInt32(split1 [i +  1 ]),Convert.ToInt32(split1 [i +  2 ])); 





得到这样的错误...



错误:'string'不包含'Location'的定义,也没有扩展方法'Location'接受类型'string'的第一个参数(你是否缺少using指令或汇编引用?)
解决方案



string labelName = "lblCity";



lblAmtInWords is label name which i given in label properties..

lblAmtInWords.Location = new Point(lblAmtInWords.Location.X, 238);
lblAmtInWords.Location = new Point(lblAmtInWords.Location.Y, 684);


i want to pass the lblCity instead of lblAmtInWords

lblCity.Location = new Point(Convert.ToInt32(split1[i + 1]), Convert.ToInt32(split1[i + 2]));



getting error like this...

error:'string' does not contain a definition for 'Location' and no extension method 'Location' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)
解决方案



这篇关于如何在c#winForm中使用Location定义声明字符串变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 09:07