Flexgrid (WinForms VB) Deleting a Row Deleted the One After Selected Row Too

Posted by: mwebster on 2 December 2020, 10:46 am EST

    • Post Options:
    • Link

    Posted 2 December 2020, 10:46 am EST

    I have an odd issue. I have a VB Winforms App using a number of FlexGrids. I have noticed that if I have for example, three rows. If the user selected the first row and hits the Delete key, I successfully capture the row number being deleted (e.row) and execute the code to delete that row from my database. The problem is that it also removes from the Flexgrid the next row although that row is not deleted from the database by my code. if I refresh the data, that second row re-appears. If a user attempts to delete the last row, my code properly identifies the row, executes the delete method and then the Flexgrid returns an out of bounds error when it tries to also delete the next non-existent row. If adding rows is enabled, there is no error when deleting the last row.

  • Posted 2 December 2020, 10:58 am EST

    New detail for you, I found that the above happens if I immediately re-populate the Flexgrid’s data after doing a delete. If I just leave it as is, everything works as expected.

  • Posted 3 December 2020, 7:01 am EST

    Hi,

    I could not replicate this behavior at my end, please refer to the sample attached, where I delete the row from the DataBase in the AfterDeleteRow event and then after deletion re-fetch the data. If you are doing something else then please provide us with a sample so that we can help you better.

    Regards,

    Prabhat Sharma.

    FgDeleteRow.zip

  • Posted 8 December 2020, 9:22 am EST

    I was using the BeforeDelete event and displaying a confirmation dialog. If the user clicked Yes, I was the carrying out the delete. That triggered the double delete issue. I have now split that up. The confirmation is displayed by the “BeforeDelete” event and the actual deletion from the database occurs in the AfterDelete event as in your example and it no longer deletes a second row.

  • Posted 9 December 2020, 6:16 am EST

    Hi,

    Yes, that would make the program delete two rows, one by the database and one by the grid.

    Glad I could help, if you have any other issue in the future, just feel free to ask.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels