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. Image for the cookie policy date

Moving a row

Hi, I am using GDBG and the insertion from the context menu is happening fine ,I am using the same code u had sent ,I am pasting it below //insert if(this.mouseDownRow > -1 && this.mouseDownCol > -1) { int position = Grid1.Binder.RowIndexToPosition(mouseDownRow); this.gridDataBoundGrid1.BeginUpdate(); DataRow dr = dt.NewRow(); this.dt.Rows.InsertAt(dr, position); this.gridDataBoundGrid1.EndUpdate(); } The newly inserted row is inserting at the last , Now I want to bring the newly added rowe from the last row to the Current Position. Could you please help me out in this. Thanks and Regards, Hsee

11 Replies

AD Administrator Syncfusion Team August 20, 2004 01:56 PM UTC

Try this. Set the DataSource using code like this. this.gridDataBoundGrid1.DataSource = new Syncfusion.Collections.DataTableWrapperList(dt); where dt is your datatable. Then in the menu handler, have code like this. if(this.mouseDownRow > -1 && this.mouseDownCol > -1) { int position = this.gridDataBoundGrid1.Binder.RowIndexToPosition(mouseDownRow); DataRow dr = dt.NewRow(); this.dt.Rows.InsertAt(dr, position); this.gridDataBoundGrid1.Refresh(); } This uses a DataTableWrapperList class that bypasses the DataView that is generally used by ADO.NET to manage the different views of data in a datatable. The problem with the standard dataview is the dataTable.Rows.Insert does not work well it it. This wrapper class attemplts to bypass this problem. Now, you woul dneed to be using at least 2.0.5.1 or 2.1.09 to have the class available to you. One problem is that there is currently a bug that causes teh wrapper class to not consistently update the cells properly if you user types a change into an exisitng cell. (It seems to update teh newly inserted rows OK, just not the existing rows in some cases.) We have corrected this problem here. If you want to get a private build with this correction, then submit a Direct Trac support incident requesting it. Otherwise, the fix will be available to you in the next public release.


AR arvind August 23, 2004 08:58 AM UTC

Hai , I took the latest version of 2.5.0.1. from ur site but the same problem is still there i.e. updating the existing record a StackOverflow exception is thrown , The latest version has the data as May 7 2004. Is this the latest version which has cleared that bug. >Try this. > >Set the DataSource using code like this. > >this.gridDataBoundGrid1.DataSource = new Syncfusion.Collections.DataTableWrapperList(dt); > >where dt is your datatable. Then in the menu handler, have code like this. > >if(this.mouseDownRow > -1 && this.mouseDownCol > -1) >{ > int position = this.gridDataBoundGrid1.Binder.RowIndexToPosition(mouseDownRow); > DataRow dr = dt.NewRow(); > this.dt.Rows.InsertAt(dr, position); > this.gridDataBoundGrid1.Refresh(); >} > > >This uses a DataTableWrapperList class that bypasses the DataView that is generally used by ADO.NET to manage the different views of data in a datatable. The problem with the standard dataview is the dataTable.Rows.Insert does not work well it it. This wrapper class attemplts to bypass this problem. > >Now, you woul dneed to be using at least 2.0.5.1 or 2.1.09 to have the class available to you. One problem is that there is currently a bug that causes teh wrapper class to not consistently update the cells properly if you user types a change into an exisitng cell. (It seems to update teh newly inserted rows OK, just not the existing rows in some cases.) We have corrected this problem here. If you want to get a private build with this correction, then submit a Direct Trac support incident requesting it. Otherwise, the fix will be available to you in the next public release.


AD Administrator Syncfusion Team August 23, 2004 09:25 AM UTC

The latest verison is 2.1 from August 17. http://www.syncfusion.com/support/updates.aspx#v21available


AR arvind August 23, 2004 09:36 AM UTC

By using this version will the performance of other grid related things going to change. >The latest verison is 2.1 from August 17. > >http://www.syncfusion.com/support/updates.aspx#v21available


AD Administrator Syncfusion Team August 23, 2004 09:41 AM UTC

I do not think so, but am not sure exactly what you are asking about. There are some changes for performance enhancements in the GridGroupingControl for 2.1.0.9, but that is about it. The major reason for the release is support of RTL and bug fixes.


AR arvind August 24, 2004 02:41 AM UTC

Thanks Clay, I took the latest version of your release and the updating the existing record is happening fine without throwing any exception ,but there is still one problem with it.The problem is generated by these by steps. 1.Retrieve the details through the data Table and set it as DataSource using Wrapper Classes 2.Change the value in the grid . 3.Change the focus from the changed row to another row. 4.Come back to the same row and then change the value of already changed row and save it. 5.The row will hold the value which was changed first.i.e. the last updated value will not be there. How to resolve this issue >I do not think so, but am not sure exactly what you are asking about. > >There are some changes for performance enhancements in the GridGroupingControl for 2.1.0.9, but that is about it. The major reason for the release is support of RTL and bug fixes.


AD Administrator Syncfusion Team August 24, 2004 06:13 AM UTC

This is the problem I was referring to above. >>One problem is that there is currently a bug that causes teh wrapper class to not consistently update the cells properly if you user types a change into an exisitng cell. The real basic problem here is that the .NET FrameWork DataTable does not support inserting a DataRow at any position other than the last row. So any direct binding technique based on DataTable/DataView will have problems trying to insert a datarow. The simplest way I know to handle this is to virtually bind the DataTable to a GridControl. This gives you the control over how you display the row order independent of datarow position in the datatable. This allows the datatable to add rows at the end (which it can do), and display them in any order you choose. Here is a sample that has a DataTable virtually bound to a GridControl that lets you insert/delete/edit rows anywhere in the grid. DataGridInsert_6440.zip


AR arvind August 24, 2004 07:26 AM UTC

Hai Clay, Th example is working fine in ur example but one peoblem is tht u have used GridControl and I am using GridDataBoundGrid ,So how can I use the GDBG instead of GridControl. >This is the problem I was referring to above. >>>One problem is that there is currently a bug that causes teh wrapper class to not consistently update the cells properly if you user types a change into an exisitng cell. > >The real basic problem here is that the .NET FrameWork DataTable does not support inserting a DataRow at any position other than the last row. So any direct binding technique based on DataTable/DataView will have problems trying to insert a datarow. > >The simplest way I know to handle this is to virtually bind the DataTable to a GridControl. This gives you the control over how you display the row order independent of datarow position in the datatable. This allows the datatable to add rows at the end (which it can do), and display them in any order you choose. Here is a sample that has a DataTable virtually bound to a GridControl that lets you insert/delete/edit rows anywhere in the grid. > >DataGridInsert_6440.zip > >


AD Administrator Syncfusion Team August 24, 2004 07:45 AM UTC

I am trying to say that I think you should use a GridControl instead of a GridDataBoundGrid. The reason is that I do not think you will be able to insert rows any place other than the last row if you use any grid (GridDataBoundGrid or WindowsForms DataGrid) that relies on databinding (through an IBindingList.ListChanged event) to maintain the data. The reason is that you cannot insert a row into a DataTable at any point other than the last row. If you require making a row appear at an arbitrary position in a grid, then I think you will be able to do it with a GridControl, but I think it will take many manhours of work to do it in a bound grid (if you can get it done at all.) Why do you need a GridDataBoundGrid?


AR arvind August 24, 2004 08:03 AM UTC

Hai , I am using GDBG because I am binding the data to the grid and doing most the operations are w.r.t. GDBG .Is it possible to bind the external dataTable as dataSource for the Control grid. >I am trying to say that I think you should use a GridControl instead of a GridDataBoundGrid. > >The reason is that I do not think you will be able to insert rows any place other than the last row if you use any grid (GridDataBoundGrid or WindowsForms DataGrid) that relies on databinding (through an IBindingList.ListChanged event) to maintain the data. The reason is that you cannot insert a row into a DataTable at any point other than the last row. > >If you require making a row appear at an arbitrary position in a grid, then I think you will be able to do it with a GridControl, but I think it will take many manhours of work to do it in a bound grid (if you can get it done at all.) > >Why do you need a GridDataBoundGrid?


AD Administrator Syncfusion Team August 24, 2004 08:26 AM UTC

Yes, the sample attached above is using a datatable as the source of data for the GridControl.

Loader.
Up arrow icon