We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Problems removing data from the DataSource

Thread ID:





37399 Nov 21,2005 09:18 PM UTC Nov 21,2005 09:54 PM UTC WinForms 1
Tags: GridControl
Asked On November 21, 2005 09:18 PM UTC

I have a need in my application to programatically remove the items from the DataSource of the GDBG. I''m using follwing code to do that: private void buttonRemove_Click(object sender, EventArgs e) { int index = GetSelectedRow(); (this.gridDataBoundGrid1.DataSource as ArrayList).RemoveAt( index - 1 ); this.gridDataBoundGrid1.Invalidate(); this.gridDataBoundGrid1.Refresh(); } NOTE: This needs to be done programatically, I can''t use the GDBG build-in delete method. All works fine till I try to delete the last item from the list. The GDBG loses it mind after that is done. From that point on it will always remove last item from the list even it the other selection in the grid was made. It appears that the grid range selection can not be reset after the removal of the last item. Also when in this state if the Up or Down arrow is pressed the exception is thrown by the grid. How can I prevent this problems and still be able to remove the data from the Data Source. Sample application is attached. To reproduce the problem: 1. Select Item 8. 2. Press: Remove and then Remove again. 3. Now select Item 5 and press Remove, last Item is removed from the list. 4. Press Up arrow twice and app will crash.


Administrator [Syncfusion]
Replied On November 21, 2005 09:54 PM UTC

You can avoid this problem by moving off the row if it is the last row before you delete it. int index = GetSelectedRow(); if(index == this.gridDataBoundGrid1.Model.RowCount) this.gridDataBoundGrid1.CurrentCell.MoveUp(); (this.gridDataBoundGrid1.DataSource as ArrayList).RemoveAt( index - 1 ); this.gridDataBoundGrid1.Invalidate(); this.gridDataBoundGrid1.Refresh();


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon