我用一个枚举的值填充了一个组合框。
现在一个组合框是文本,对吧?因此我使用了一个getter和一个setter。我在阅读文本时遇到了问题。
这是代码:
public BookType type
{
get
{
return (BookType)Enum.Parse(typeof(BookType), this.typeComboBox.Text);
}
set
{
this.typeComboBox.Text = value.ToString();
}
}
由于某些原因,当我在组合框上选择一个项目时,this.typeComboBox.Text
总是返回一个空字符串。
有人看到我做错了什么吗?
EDIT: I have come to the conclusion that the problem lies in timing. The point in time at which I summon the text is indeed after I changed the combobox, but still before that value is parsed as a value. Problem fixed in a different way now, thanks for all the ideas.