I think I see what you are are trying to accomplish.
Can you store your listboxes selectedIndex as a Form (or class) level
declaration?
You can then hook into the SelectedIndexChanged event on your listbox, some
pseudo code would look like this:
// class or form level declarations
int lastSelectedIndex=0
bool textBoxesChanged=false
On textbox_TextChanged
-set textBoxesChanged=true
On listbox_OnSelectedIndexChanged
-if textBoxesChanged == true
-if prompt for save == yes
-do a save for the object referred to by lastSelectedIndex by retrieving
data from
textboxes
-set textBoxesChanged=false
-set lastSelectedIndex = listbox.SelectedIndex
-load up textboxes with new selected item's data
Done
You might use SelectedValue instead of selected index if your listbox values
are referencing objects in an array or database...
Hope it helps.
--
Cheers,
Jonathan
"amber" wrote:
Hi there.
I'm using Windows Forms.
Maybe I'm going about this in the wrong way.
What I'm doing is this:
I have a listbox on a form with a bunch of text boxes. The values in the
textboxes are linked to what is selected in the listbox.
If a user edits any of the textboxes, then tries to move off the current
item in the listbox, I need to prompt to save, then save the current record.
My problem is, the new item in the listbox is already selected at this
point...
Make sense?
Cheers,
Amber