CurrencyManager Qestion

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Engineerik

    CurrencyManager Qestion

    I think I need to use a currency manager for this job but I'm not sure
    how to make it work.
    Using a dataview as the datasource for a datagrid.
    Sorting not allowed per the tablestyles.
    There is a column in the table which is not displayed which controls
    the display order. To move a row (or group of rows) in the table
    select the rows to move and click the appropriate button next to the datagrid.
    One button shifts rows up. A second button shifts rows down.
    That much works fine.
    After changing the integer values in the displayorder column I reset the
    dataview.sort = "displayord er" and the selected rows now appear in
    the proper order shifted one row from their previous position.

    After shifting the rows I reselect the rows.
    My problem is that if I then click the shift button a second time
    only the first row selected is shifted and after the shift only that
    one shifted row is selected.

    Any suggestions?

    My shift up Code:
    Private Sub cbShiftUp_Click (ByVal sender As System.Object, ByVal e As
    System.EventArg s) Handles cbShiftUp.Click
    Dim dvShift As DataView = dgFleetList.Dat aSource
    Dim drvRow As DataRowView
    Dim drvSwap As DataRowView
    Dim iPUR As Integer
    Dim iSwap As Integer
    Dim iR As Integer
    Dim iSel As Integer
    Dim alChosen As New ArrayList()

    'Exit if shifting up is trivial
    If dvShift.Count < 2 Then Exit Sub
    If dgFleetList.IsS elected(0) Then Exit Sub

    'Initialize iPUR (Previous Unselected Row)
    iPUR = 0

    'Empty the Chosen Row Arraylist
    alChosen.Clear( )

    'Loop through rows
    For iR = 1 To dvShift.Count - 1
    If dgFleetList.IsS elected(iR) Then
    'Swap display position values with iPUR
    drvRow = dvShift.Item(iR )
    iSwap = drvRow.Item("Di splayOrder")
    drvSwap = dvShift.Item(iP UR)
    drvRow.Item("Di splayOrder") = drvSwap.Item("D isplayOrder")
    alChosen.Add(iR - 1)
    drvSwap.Item("D isplayOrder") = iSwap
    Else
    'Reset iPUR
    iPUR = iR
    End If
    Next

    dvShift.Sort = "DisplayOrd er"

    'Reselect chosen rows
    For iR = 0 To alChosen.Count - 1
    dgFleetList.Sel ect(alChosen(iR ))
    Next

    End Sub

Working...