ComboBox.SelectedValue;获取ComboBox.ValueMember的值
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/09 17:58:49
ComboBox.SelectedValue;获取ComboBox.ValueMember的值
string a = this.ComboBox.SelectedValue;
int a = this.ComboBox.SelectedValue;
为什么都提示无法将object隐式转换?
string a = this.ComboBox.SelectedValue;
int a = this.ComboBox.SelectedValue;
为什么都提示无法将object隐式转换?
![ComboBox.SelectedValue;获取ComboBox.ValueMember的值](/uploads/image/z/4388414-14-4.jpg?t=ComboBox.SelectedValue%3B%E8%8E%B7%E5%8F%96ComboBox.ValueMember%E7%9A%84%E5%80%BC)
那就用
string a = this.ComboBox.SelectedValue.ToString();
int a = int.Parse(this.ComboBox.SelectedValue.ToString());
因为 this.ComboBox.SelectedValue 是 object,
所以我将他改成 string 后,再改成数量,如此一来就能让他变成int 了.
string a = this.ComboBox.SelectedValue.ToString();
int a = int.Parse(this.ComboBox.SelectedValue.ToString());
因为 this.ComboBox.SelectedValue 是 object,
所以我将他改成 string 后,再改成数量,如此一来就能让他变成int 了.