作业帮 > 综合 > 作业

ComboBox.SelectedValue;获取ComboBox.ValueMember的值

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/06/17 16:48:30
ComboBox.SelectedValue;获取ComboBox.ValueMember的值
string a = this.ComboBox.SelectedValue;
int a = this.ComboBox.SelectedValue;
为什么都提示无法将object隐式转换?
ComboBox.SelectedValue;获取ComboBox.ValueMember的值
那就用
string a = this.ComboBox.SelectedValue.ToString();
int a = int.Parse(this.ComboBox.SelectedValue.ToString());
因为 this.ComboBox.SelectedValue 是 object,
所以我将他改成 string 后,再改成数量,如此一来就能让他变成int 了.