locked
Capturing a previous selecteditem RRS feed

  • Question

  • I have created an event handler for switching between collection items

    "Patient_Visits_SelectionChanged()" 

    When I change the selection, I want to affect the "previous" selecteditem (the item that was selected before the event).  Any way to capture this so that I can change properties to that selection?

    Scott

    Monday, March 18, 2013 6:05 PM

Answers

  • Paul, I took your advice in storing it in a variable, but I do it before the event (to capture the selecteditem) and then when the SelectedItemChanged event fires, I update the fields and then associate the variable with the new selecteditem. :) Scott
    Monday, March 18, 2013 8:47 PM

All replies

  • Hi Scott,

    At first glace, I would say "store it in a variable", when your _SelectionChaged() event fires.

    Maybe, if you provide some extra info what exactly you want to achieve, forum readers come up with additional suggestions.


    paul van bladel

    Monday, March 18, 2013 7:06 PM
  • Paul,

        I thought of that, but doesn't the SelectionChanged event fire 'after' the selection has been changed and therefore the previously selecteditem would no longer be referenced?

         I am using a user locking mechanism (maybe there's a better way to do this) of adding a datetime field and string for who is currently editing a record so that other users won't access that same record.  I set the fields when the user "edits" the record, then remove when the user "saves" their changes, but the SelectionChanged event can also fire because the user can change the record they're editing before saving.  Does that make sense?

    Scott

    Monday, March 18, 2013 7:10 PM
  • Hi Scott,

    Why would you implement a "locking mechanism"? LightSwitch has excellent built-in data conflict resolution. Are you familiar with this?

    paul.


    paul van bladel

    Monday, March 18, 2013 7:20 PM
  • Paul,

        I am familiar with it, but those "accept changes" conflict popups tend to confuse my users.  I was trying to avoid the user being able to change a record that might get that popup.

    Scott

    Monday, March 18, 2013 7:22 PM
  • Paul, I took your advice in storing it in a variable, but I do it before the event (to capture the selecteditem) and then when the SelectedItemChanged event fires, I update the fields and then associate the variable with the new selecteditem. :) Scott
    Monday, March 18, 2013 8:47 PM