I've added a button to a Windows form that allows a user to move a selected row from datagrid 1 to datagrid 2.
Datagrid 2 has a column that holds sequential numbers 1, 2, 3, 4..named "priority order" but that does not exist on datagrid 1.
How can the next number be assigned to the newly added row after the user decides to move it from dg1 to dg2?
Here is the code that places the row from datagrid 1 to datagrid 2:
Private Sub btnMoveDown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMoveDown.Click
If grdAvailableDistributors.E
nabled Then
'Make sure a row is selected first
If (grdAvailableDistributors.
RowSel > 0) Then
grdAvailableDistributors.A
llowDelete
= True
'Add the selected category to the assigned grid
grdCurrentDistAssignment.R
ows.Add()
grdCurrentDistAssignment.S
etData(grd
CurrentDis
tAssignmen
t.Rows.Cou
nt - 1, "Distributor #", _
grdAvailableDistributors.G
etData(grd
AvailableD
istributor
s.RowSel, "Distributor #"))
grdCurrentDistAssignment.S
etData(grd
CurrentDis
tAssignmen
t.Rows.Cou
nt - 1, "Type", _
grdAvailableDistributors.G
etData(grd
AvailableD
istributor
s.RowSel, "Type"))
grdCurrentDistAssignment.S
etData(grd
CurrentDis
tAssignmen
t.Rows.Cou
nt - 1, "Name", _
grdAvailableDistributors.G
etData(grd
AvailableD
istributor
s.RowSel, "Name"))
'Remove the selected category in the available grid
grdAvailableDistributors.R
emove(grdA
vailableDi
stributors
.RowSel)
'Don't select anything in the source grid
grdAvailableDistributors.S
elect(-1, -1, -1, -1)
'Sort the grids
grdAvailableDistributors.S
ort(C1.Win
.C1FlexGri
d.SortFlag
s.Ascendin
g, 0)
grdCurrentDistAssignment.S
ort(C1.Win
.C1FlexGri
d.SortFlag
s.Ascendin
g, 0)
Me.grdCurrentDistAssignmen
t.Select(M
e.grdCurre
ntDistAssi
gnment.Cou
nt - 1, 0)
End If
End If
End Sub
any help on this is very much appreciated.
Thank you.
Start Free Trial