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.

DataGrid/DataSet DataRow index problem when inserting rows

Thread ID:

Created:

Updated:

Platform:

Replies:

1184 Oct 2,2002 09:27 AM Oct 7,2002 11:00 AM Windows Forms 6
loading
Tags: FAQ
PeteB
Asked On October 2, 2002 09:27 AM

I have been playing with a great sample from the FAQ 5.6 deriving a custom column style to nest a comboBox in a DataGrid column. Everything works fine until I insert a new row into the dataset instead of adding the row (using the Rows.InsertAt() method). TC_DataSet.Tables["TC_Table"].Rows.InsertAt(newRow1,TC_Row); TC_DataSet.Tables["TC_Table"].AcceptChanges(); The record shows up in the DataGrid but when you start clicking on other rows(or using cursor keys) to move to other rows, C# gives an invalid index message: "System.IndexOutOfRangeException" The Grid seems to think there is one more row than there should be - it doesn't seem to be sync'ed up with the dataset. I have seen some other similar complaints on the net but no indication of what the issue might be. Any insight would be appreciated.

Administrator [Syncfusion]
Replied On October 3, 2002 07:19 AM

That sample was modified last week to handle some last row problems, so you might check to see if you have the latest version. You might also try calling refresh on the datagrid's currency manager. CurrencyManager cm = (CurrencyManager) this.BindingContext[this.myDataGrid.DataSource, this.myDataGrid.DataMember]; cm.Refresh(); to see if that gets things back in sync.

PeteB
Replied On October 3, 2002 11:37 AM

I gave it a shot but it is still giving the same exception. It seems to be in the System.Data.DataView.OnListChanged method but I can't be sure - just can't nail it down. I have attached FAQ example 5.6 and added a button to Insert a row. If you run the sample, click on the button and then start clicking rows in the grid, you will see some interesting results.

Administrator [Syncfusion]
Replied On October 4, 2002 04:55 AM

We modified that sample a few days ago with a suggestion by Gerald Walsh that I think takes care of the problem you are having. We removed some code at the top of the Edit method and the entire ComboMadeCurrent method. We added a handler for SelectionChangeCommitted. You might try getting the sample code again and trying your add button with the new code.

PeteB
Replied On October 4, 2002 06:42 AM

The updated code does not seem to be there - the ComboMadeCurrent method is still there. I checked the samples in 5.6, 5.40 & 5.54. Would you have a link to it? Thanks!

Administrator [Syncfusion]
Replied On October 4, 2002 11:20 AM

Oops. Our overnight upload from our local server has been broken for a couple of days, so the automatic upload has not been happening. I did a manual upload so you should be able to get the new files now. Sorry.

PeteB
Replied On October 7, 2002 11:00 AM

Well...I have tried quite a few things including; - the new sample code - refreshing currency manager but it still will not work correctly. If you have any further suggestions, I would appreciate it. If you could take a quick look...I have attached the new 5.6 example with a button to insert a row into your grid: Run the example, click the button to insert a row and then change the city in the combobox for each row, particularly the rows after the inserted row. Duplicate rows appear and values in the city column can get mixed up. Eventually an exception will appear. I can not explain why.

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.

;