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

Altering row index using default view

Thread ID:

Created:

Updated:

Platform:

Replies:

14554 May 28,2004 04:29 PM UTC May 28,2004 07:26 PM UTC WinForms 2
loading
Tags: GridControl
Patrick Noble
Asked On May 28, 2004 04:29 PM UTC

I have created a data bound grid sourced from a datatable and using a default view to sort the rows. I have an up and a down button to enable the user to select a row and move it up and down the grid by altering a sort order field. It works fine as long as I keep going in the same direction, up or down, but gets the sort order wrong if I switch directions without moving off the row. The sort order is column 7 in the grid so I increment/decrement this field in the current row and increment/decrement the field in the row above/below. Anything obviously wrong before I supply more details? The code is as follows: Private Sub btnUp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUp.Click ''move the selected row one place up the list Dim drEmployee1, drEmployee2 As dsEmployee.EmployeeRow Dim rowIndex, rowDatasource As Int32 Dim cc As GridCurrentCell rowIndex = gridEmployee.Binder.CurrentRowIndex If rowIndex > 1 Then gridEmployee.BeginUpdate() gridEmployee(rowIndex, 7).CellValue -= 1 gridEmployee(rowIndex - 1, 7).CellValue += 1 cc = gridEmployee.CurrentCell cc.MoveTo(rowIndex - 1, 0) gridEmployee.EndUpdate() End If End Sub Private Sub btnDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDown.Click ''move the selected row one place down the list Dim drEmployee1, drEmployee2 As dsEmployee.EmployeeRow Dim rowIndex, rowDatasource As Int32 Dim cc As GridCurrentCell rowIndex = gridEmployee.Binder.CurrentRowIndex If rowIndex < gridEmployee.Model.RowCount - 1 Then gridEmployee.BeginUpdate() gridEmployee(rowIndex, 7).CellValue += 1 gridEmployee(rowIndex + 1, 7).CellValue -= 1 cc = gridEmployee.CurrentCell cc.MoveTo(rowIndex + 1, 0) gridEmployee.EndUpdate() End If End Sub

Administrator [Syncfusion]
Replied On May 28, 2004 06:21 PM UTC

To add detail (confusion) I can report that the problem occurs because the cell value of BOTH rows is altered by the second CellValue statement, but only after changing direction. So if I keep going up, for example, the CellValue statements work as expected, but if I click down once, then the first CellValue statement correctly increments column 7 of rowIndex but the second one appears to decrement column 7 of rowIndex+1 AND rowIndex.

Administrator [Syncfusion]
Replied On May 28, 2004 07:26 PM UTC

You might try calling gridEmployee.Binder.EndEdit after you change each value.

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.

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

;