更改listBox的值

时间:2015-04-11 06:24:22

标签: c# winforms

WinForms 中如何更改 listBox 中所选项目的值? 我的代码不起作用:

    private void button11_Click(object sender, EventArgs e)
    {
        listBox1.Text = "new value";
        listBox1.ValueMember = "new value";
        listBox1.SelectedValue = "new value";
        listBox1.SelectedItem = "new value";
        listBox1.Name = "new value";
    }

enter image description here

EDIT1:

enter image description here

2 个答案:

答案 0 :(得分:1)

试试这个:

listBox1.Items.Insert(listBox1.SelectedIndex, "new Value");
listBox1.Items.Remove(listBox1.SelectedItem);

答案 1 :(得分:1)

只是:

listBox1.Items[listBox1.SelectedIndex] = "new Value";
相关问题