Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1180
Loss of Value ActiveRow
posted

Before you perform an action I show a certain form.
Ex: Before deleting a record I show a form asking if it really is to delete.
After doing this I wanted to use Grid.ActiveRow.Cells (1). Value to build a SQL to do the deletion.
It turns out that after showing the form I lose the value of active row.
As if I did not have any active line.

  • 469350
    Offline posted

    What event of the grid are you using? To show a prompt for deleting rows, you should use the BeforeRowsDeleted event of the grid. Set e.DisplayPromptMsg to false in the event to cancel the grid's default prompt and then you can show your own dialog. Then you can set e.Cancel to true if the user decided to cancel the deletion.

  • 69832
    Offline posted

    The grid maintains the ActiveRow until you explicitly set the property to null, or the row is removed from the Rows collection. Assuming that at the time you show your confirmation dialog the rows has not yet been removed, the ActiveRow should still be available.

    One thing to note is that the control exposes an event, BeforeRowDeactivate, which fires right before a row that was the ActiveRow is deactivated; you should add a handler for this event and put a breakpoint in it, so you can see what is triggering the deactivation of the row.