Thursday 15 January 2015

c# make multiple different methods trigger a bool -



c# make multiple different methods trigger a bool -

i'm trying grab , handle content changes of listview (add, rename, delete items) on own there no predefined events job. read approach place , switch bool in functions changes ugly coding, i'd avoid. that's why i'm asking if knows way register multiple methods triggers bool in turn tells if considerable changes made, pseudo code:

bool changesdetected = false; void additem() {...} void renameitem() {...} void removeitem() {...} void watchoutforchanges() { if(additemhascompleted || renameitemhascompleted || removeitemhascompleted) { changesdetected = true; } } void formclosing() { if(changesdetected) { // save file selection } }

any ideas appreciated!

you can create own delegate, event, , event handler, , invoke method capture changes. however, think looking way handle events listview has (in windows forms):

bool changesdetected = false; public void setup() { listview view = new listview(); view.afterlabeledit += watchoutforchanges; view.controladded += watchoutforchanges; view.controlremoved += watchoutforchanges; } public void watchoutforchanges(object sender, eventargs e) { changesdetected = true; }

c# methods triggers boolean

No comments:

Post a Comment