开发者

Updating a listbox item value

开发者 https://www.devze.com 2023-04-11 18:30 出处:网络
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:

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

精彩评论

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

关注公众号