开发者

Updating a listbox item value

I have a listbox and each ite开发者_运维技巧m is made up of an object called Part which consists of 2 strings Part.PartNo & Part.Filename. I want to do something like this:

((Part)drawingList.Items[activeItem]).Filename = "My new value";

But I'm getting the error that it can't be assigned to because it is read only.


Listbox Items are strings (Winforms) so you'll have to parse the string and extract the two values. If there is a space separating them you'll have to do a...

string[] tokens = listbox.items[i].split(new char[] {' '});
Part p = new Part() {partno = Convert.ToInt32(tokens[0]), filename = "my new value"};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜