BeforePositionChange event?

  • Thread starter Thread starter Joe
  • Start date Start date
J

Joe

I'm looking for an event which is fired before the current row changes.
Similar to the CM.PositionChange event but right before it actually changes.

I thought I could use the RowChanging event of the DataTable but this only
gets fired if the row changed.

Thanks,
Joe
 
I don't believe you can get what you want out of the DataTable. The reason
for this is that the DataTable is basically the backing store for the
CurrencyManager. It is the CurrencyManager that keeps track of the current
row in the DataGrid. And it only talks to the DataTable if the person who is
interacting with the interface does something to update the DataTable. Sorry.
 
Ok. Then what about the DataGrid. Is there an event that is fired right
before the position changes?

For example I have a DataGrid displaying 20 rows. If the user is currently
on row 2 and then click to row 18 is there an event to tell me this happened
before the position actually changes to row 18?

The reason for this is that I have some data that may need to be saved if
the user is changing records.
 
Nothing springs immediately to mind for *before* the move is made. However,
if the DataGrid is tied to a DataSet, then the RowChanging event comes into
play. Since you ask the question, I can only assume that it's not. But
perhaps the easiest solution would be to move your data into a DataSet, just
for that reason.
 
How about storing a static variable in the PositionChange event handler?

As you enter the event handler, you will either have null/Nothing or a
reference to the last row that was accessed.

Do your "business logic"

As you leave the event handler, update the static variable to reference the
current row that you can then access when the event handler is triggered
again.
 
Back
Top