文本框组件错误 [英] textbox components error
本文介绍了文本框组件错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我放入表单并将修饰符更改为public时,我将创建一个文本框组件,即Alphabet_TextBox发生此错误:
Hi,
I make a text box components Namely alphabet_TextBox when i put in form and change modifiers to public This error happens:
Error 1 Inconsistent accessibility: field type ''WindowsFormsApplication2.Alphabet_TextBox'' is less accessible than field ''WindowsFormsApplication2.frmEdit.alphabet_TextBox2''
这是form.designer中的代码:
and here''s code in form.designer:
public Alphabet_TextBox alphabet_TextBox2;
help plz.
help plz.
推荐答案
不要这样做!
永远不要公开您的组件-这会导致表单的设计被锁定"-您无法更改表单的工作方式,因为您不知道外界对您的文本框所做的事情.
而是使用公共属性:
Don''t do it!
Never make your components public - it causes the design of your form to be "locked" - you cannot change the way the form works, because you do not know what the outside world has done with your textbox.
Instead, use a public property:
public AlphabetText
{
get { return alphabet_TextBox2.Text; }
set { alphabet_TextBox2 = value; }
}
然后,只要您的属性返回相同的值,就可以更改表单的工作方式,而无需外界干预.
You can then change the way your form works without the outside world being any the wiser, provided that your property returns the same values.
这篇关于文本框组件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文