我有一個列表框,其中項目是一個結構。該結構包含兩個字符串。一個用於標題,另一個用於純文本。現在我想更改列表框中現有項目中的文本。有沒有辦法做到這一點,而不刪除現有的並將更新版本添加到列表中?C#更改現有列表框項目中變量的值
這就是我想做的事情,
((TextItemRecord) listbox1.Items[myListbox1.BeforeIndex]).text = "Blablabla";
編譯器說,當我嘗試做這個「無法修改取消裝箱轉換的結果」。任何解決方案
結構,
struct TextItemRecord
{
public UInt64 address;
public string name, text;
public TextItemRecord(UInt64 address, string name)
{
this.address = address;
this.name = name;
this.text = "";
}
public override string ToString()
{
return name;
}
}
對不起鄉親,我不知道這個網站是如何工作的
你將要需要給我們一些代碼,以幫助您 –
嗨,你可以檢查此鏈接要弄清楚它是如何工作的。 http://stackoverflow.com/help/how-to-ask,你需要幫助我們來幫助你。 –
看看[這個](http://stackoverflow.com/questions/17280547/why-can-i-not-modify-the-result-of-an-unboxing-conversion) –