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.
Unfortunately, activation email could not send to your email. Please try again.

Problems removing data from the DataSource

Thread ID:

Created:

Updated:

Platform:

Replies:

37399 Nov 21,2005 04:18 PM Nov 21,2005 04:54 PM Windows Forms 1
loading
Tags: GridControl
kstoj
Asked On November 21, 2005 04:18 PM

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.

DeleteTest.zip

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

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();

CONFIRMATION

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.

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.

;