在 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";
}
EDIT1:
答案 0 :(得分:1)
试试这个:
listBox1.Items.Insert(listBox1.SelectedIndex, "new Value");
listBox1.Items.Remove(listBox1.SelectedItem);
答案 1 :(得分:1)
只是:
listBox1.Items[listBox1.SelectedIndex] = "new Value";