您好,编码人员.帮助vb.net错误 [英] Hello Coders. Help with vb.net error
问题描述
我有此代码:
I have this code :
this.toolStripCategories.Location = new Point(3, 138);
this.toolStripCategories.Name = "toolStripCategories";
this.toolStripCategories.Size = new Size(258, 25);
this.toolStripCategories.TabIndex = 6;
this.toolStripCategories.Text = "toolStrip1";
this.tsbAddCategory.DisplayStyle = ToolStripItemDisplayStyle.Text;
this.tsbAddCategory.Image = (Image)componentResourceManager.GetObject("tsbAddCategory.Image");
this.tsbAddCategory.ImageTransparentColor = Color.Magenta;
this.tsbAddCategory.Name = "tsbAddCategory";
this.tsbAddCategory.Size = new Size(33, 22);
this.tsbAddCategory.Text = "Add";
this.tsbAddCategory.Click += new EventHandler(this.tsbAddCategory_Click);
this.tsbEditCategory.DisplayStyle = ToolStripItemDisplayStyle.Text;
this.tsbEditCategory.Enabled = false;
this.tsbEditCategory.Image = (Image)componentResourceManager.GetObject("tsbEditCategory.Image");
this.tsbEditCategory.ImageTransparentColor = Color.Magenta;
this.tsbEditCategory.Name = "tsbEditCategory";
this.tsbEditCategory.Size = new Size(31, 22);
而且它一直给我这个错误.
警告1变量"componentResourceManager"未声明或从未分配.
我不知道这是怎么回事.请帮助
And it keeps giving me this error.
Warning 1 The variable ''componentResourceManager'' is either undeclared or was never assigned.
I dunno what am doing wrong. Please help
推荐答案
那看起来像是一个错字.尝试使用ComponentResourceManager
并在其前面使用大写字母C.
希望对您有帮助
That looks like a Typo. TryComponentResourceManager
with a capital C at the front.
Hope this helps
警告?!它应该给您一个编译错误!
正如韦恩已经说过的那样,ComponentResourceManager
是一个类,以大写的C开头.
Warning?! It should give you a compilation error!
As Wayne already said,ComponentResourceManager
is a class and starts with a capital C.
非静态字段,方法或属性''System.Resources.ResourceManager.GetObject(string )''如果ts小,则上面的警告是一个警告
An object reference is required for the non-static field, method, or property ''System.Resources.ResourceManager.GetObject(string)'' if ts a small c then the one above is a warning
GetObject是ComponentResourceManager
的实例方法.您需要一个类的实例才能访问此方法(似乎尚未创建).
添加此行:
GetObject is an instance method of ComponentResourceManager
. You need an instance of the class to access this method, which you seem to have not created.
Add this line:
ComponentResourceManager componentResourceManager = new componentResourceManager();
//or the other overload passing Type as a parameter
现在这行很有意义,
now this line makes sense,
componentResourceManager.GetObject("tsbAddCategory.Image");
有关该类的更多信息,请检查MSDN链接- ComponentResourceManager类 [ ^ ]
希望这可以帮助! :thumbsup:
For more information about the class, check the MSDN link - ComponentResourceManager Class[^]
Hope this helps! :thumbsup:
这篇关于您好,编码人员.帮助vb.net错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!