我想创建一个可以编辑班级字段的表单TagHandler
。
所以我决定作为参数传递给构造函数TagHandler tag
where tag
- 是我要编辑的标签。在我的表单中,我有一个字段tag
我对其进行编辑,然后获取其数据。
例如,在我的主窗体中,我有一个列表框MouseDoubleClick
method
void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
{
int index = listBox1.SelectedIndex;
TagHandler tg = listData[index];
EditTag edit = new EditTag(tg);
if (edit.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
listData[index] = edit.Tag as TagHandler;
}
}
Where EditTag
是一种形式
public partial class EditTag : Form
{
public TagHandler tag { set; get; }
public EditTag(TagHandler tag)
{
InitializeComponent();
this.CenterToParent();
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.tag = tag;
this.label2.Text = tag.Tag;
}
private void button1_Click(object sender, EventArgs e)
{
tag.Data = richTextBox1.Text;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
}
但我有这样的错误
可访问性不一致:属性类型“XmlMissionEditor.TagHandler”的可访问性低于属性“XmlMissionEditor.EditTag.tag”
可访问性不一致:参数类型“XmlMissionEditor.TagHandler”比方法“XmlMissionEditor.EditTag.EditTag(XmlMissionEditor.TagHandler)”的可访问性较差
有什么问题?我什至设置了tag
字段为public
但它仍然显示相同的错误。
我的课TagHandler
看起来像这样
[Serializable]
class TagHandler
{
private string data;
private string tag;
private Color color;
private List<AttributeHandler> attributes;
public TagHandler(string tag, bool close)
{
attributes = new List<AttributeHandler>();
if (close)
{
string s = "/" + tag;
this.tag = s;
}
else
{
this.tag = tag;
}
}
public string Tag
{
get { return tag; }
set { tag = value; }
}
public string Data
{
get { return data; }
set { data = value; }
}
...other methods
}