Combobox的内容在Listview Visual Studio 2013中以其他方式显示

时间:2013-11-09 22:13:13

标签: c# listview combobox

我正在尝试通过列表向组合框添加项目。组合框内容是预先确定的字符串,但每当我运行它时,listview显示数字而不是组合框内的文本

这是我的命令:

ListView.Items.Add(Name.SelectedIndex +" "+ Category.SelectedIndex +" "+ Double.Parse(Price.Text));

1 个答案:

答案 0 :(得分:0)

SelectedIndex是索引(即:如果它是列表中的第二项,它将是2)

你想要的是SelectedText所以:

Combobox.Items.Add(Name.SelectedText+" "+ Category.SelectedText+" "+ Double.Parse(Price.Text));

我假设名称和类别是下拉列表。