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"};
精彩评论