Thursday, 15 August 2013

c# - connect object to listViewItem -



c# - connect object to listViewItem -

i have overview of objects, displayed in listview. when object selected want show form containing more details selected item.

public lessonform(lesson foo) [get , display data]

[...]

lessonlistview.itemactivate += lessonselected; void lessonselected(object sender, eventargs e) { lesson ??? = //requestion magic here. new lessonform(???).show(); }

since listviewitems acutally texts , not programmatically connected lesson-object used create them, have not found proper way find respective lesson-object each listviewitem. sure

lesson ??? = program.listofalllessons.find((candidate) => { homecoming candidate.plaintextname == selecteditem.text //abbrev. on purpose });

however think undisputed that horrible code, on more 1 level. basically: wish listviewitem have an

obj underlyingobject;

field allows easy access object represented listviewitem. there functionality allows this?

you utilize tag property store associated object when creating listviewitem. tag of type object you'd need cast appropriately when read it.

c# winforms listview user-interface control

No comments:

Post a Comment