Move up and down list


Author
Message
Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I would like to have a list control that allow user to adjust record position by clicking move up/down. How does it usually be implemented using SF?

Thank you

Joseph-Carl Theodat
Joseph-Carl Theodat
StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)StrataFrame Beginner (29 reputation)
Group: Forum Members
Posts: 29, Visits: 79
Hi,

you can do it by adding two buttons (up & down) on your form and adjust the Items Collection of your ListBox control.

For the Up & Down: change the position of your current selected item in the collection

Be careful at the boundaries of your collection.

Michael Reese
Michael Reese
StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Hi Chan

You can use code something like this where LvNavigate is your listview.

Private Sub lvNavigate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvNavigate.SelectedIndexChanged

If lvNavigate.SelectedItems.Count > 0 Then

Me.BoDevTools1.NavigateToPrimaryKey(CType(Me.lvNavigate.SelectedItems(0).Tag, Integer))

End If

End Sub

Private Sub BO_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles BoDevTools1.Navigated

If BoDevTools1.Count > 0 Then

SetListViewIndex(BoDevTools1.ID)

End If

End Sub

Private Sub SetListViewIndex(ByVal PrimaryKey As Integer)

'-- Establish Locals

Dim loItem As ListViewItem

'-- Remove any selected items

For Each loItem In Me.lvNavigate.Items

'-- See if the item matches the PK

If CType(loItem.Tag, Integer) = PrimaryKey Then

'-- Select the list item

loItem.Selected = True

'-- Make sure it is visible

lvNavigate.EnsureVisible(lvNavigate.Items.IndexOf(loItem))

Else

'-- Turn off the selection

loItem.Selected = False

End If

Next

End Sub

Private Sub lvNavigate_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lvNavigate.SelectedIndexChanged

If lvNavigate.SelectedItems.Count > 0 Then

Me.BoDevTools1.NavigateToPrimaryKey(CType(Me.lvNavigate.SelectedItems(0).Tag, Integer))

End If

End Sub

Private Sub BO_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles BoDevTools1.Navigated

If BoDevTools1.Count > 0 Then

SetListViewIndex(BoDevTools1.ID)

End If

End Sub

Private Sub SetListViewIndex(ByVal PrimaryKey As Integer)

'-- Establish Locals

Dim loItem As ListViewItem

'-- Remove any selected items

For Each loItem In Me.lvNavigate.Items

'-- See if the item matches the PK

If CType(loItem.Tag, Integer) = PrimaryKey Then

'-- Select the list item

loItem.Selected = True

'-- Make sure it is visible

lvNavigate.EnsureVisible(lvNavigate.Items.IndexOf(loItem))

Else

'-- Turn off the selection

loItem.Selected = False

End If

Next

End Sub


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Joseph and Michael are both correct.  Generally, as Joseph had mentioned, we will add two buttons and then managed the index position of the list.  We will then manage the BO position through the SelectedIndexChanged event of the listview.  When we populate a ListView, especially if you are populating using a BO, you can store the PK of each row in the tag property (Michaels post mentions how to do this).  This will give you a value to seek on.  If you look at the AdvancedListViewPopulation sample, this sample gives you an example of this...as does the CRM sample application for the population of the credit cards in the customer maintenance.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search