c# - how can i find a list item with a list item's given parameter? -
how can find list item list item's given parameter?
my list defined as;
public list<column0a> list0a = new list<column0a>();
and has items as;
list0a.add(new column0a(header.type, message.receievetime, message.importance, message.data));
i have listed message.receivetime's on gui depending on list. want is; when user click on receivetime label, want show tooltip shows list item's (same receive time) data this:
header: header.type
receive time: receivetime
importance: message.importance
data: message.data
how can find same receievetime list instance? should use linq? give me code sample?
thanks.
i'd recommend use id lookup instead of time stamp. if info comes database, primary key field. makes intent clearer, , allows select right info if 2 happen have same time. select item:
int theidimlookingfor = //the 1 clicked on column0a myitem = list0a.single(x => x.id == theidimlookingfor); //display myitem's info in tooltip
(single
linq extension) if you're not clear on it, should study difference between single
, first
, singleordefault
, , firstordefault
, , choose 1 appropriate situation.
Comments
Post a Comment