By Thomas Holste - 12/19/2015
Hi there,
how do I get the index of an selected item in a stratalistview. The code I found in an older post by Trent seem to be for the listview?
Dim index As Integer = LV.SelectedIndices(0)
But unfortunately "selectedindices" is not a member of the stratalistview.
Thanks a lot and Merry Christmas for all of you
Thomas
|
By Edhy Rijo - 12/20/2015
Hi Thomas,
When you are populating the StrataListView, there is a collection property named "CustomData" to which you should add your Primary Key field value and then you can access it to know the record that is selected in the list.
Here is a sample code of how I populate one of my StrataListView with a checkbox column:
For Each bo As bizTransactionItems In .BusinessObject.GetEnumerable() '-- Create a new item. The item is actually the first column as well. ' The first column will have an icon and a checkbox item = New StrataListViewItem(String.Empty, String.Empty, MicroFour.StrataFrame.UI.Rendering.Enums.StrataCheckBoxSupportType.TwoState, MicroFour.StrataFrame.UI.Rendering.Enums.StrataCheckedState.Unchecked) '-- Create the sub items. A sub-item is ultimately nothing more than a column. item.SubItems.Add(bo.cfp_CardDescription, String.Empty) item.SubItems.Add(Format(bo.ItemQty, "n0"), String.Empty) item.SubItems.Add(bo.CardStartSerialNumber.ToString, String.Empty)
Dim groupTitle As String = String.Format("Reference #: {0} Processed by {1} on {2}", bo.CurrentRow.Item("ReferenceNo"), bo.CurrentRow.Item("ReceivedBy"), bo.CurrentRow.Item("ReceivedOn")) item.Group = .Groups(groupTitle, True, False)
'-- Create a custom data item that stores the primary key of this record item.CustomData.Add("PrimaryKey", bo.PK_TransactionItems)
'-- Add the item to the list Me.lstCSVActivationExport.Items.Add(item) Next
Notice how I create a CustomData item named "PrimaryKey" and store the business object primary key value.
Then to read it use something like this:
If Me.lstCSVActivationExport.SelectedItems.Count > 0 Then '-- Attempt to navigate to the selected record in the list view. Me.bizCSVActivationExport.NavigateToPrimaryKey(Me.lstCSVActivationExport.SelectedItems(0).CustomData("PrimaryKey")) End If
It has been a while, but I posted a message on 9/21/2010 with some enhancements I did to a subclass of the StrataListView that could be useful to you. Today I am using DevExpress grids for 99% of my list needs, but the SF StrataListView is very powerful and fast. Here is the link for that post: http://forum.strataframe.net/FindPost28459.aspx
Also search the forums for "StrataListView" for great posts that will also help you out.
Good luck!!!!
|
By Thomas Holste - 12/20/2015
Hi Edhy,
thanks for your detailed answer. I already found your listview-class.
But I want to use the stratalistview in bound mode. I get bibliographical data through a Rest-API, assign it to an objects, than save These objects in a List of Objects, which populate the listview. Works all fine but I want to move and remove and add objects so I need the index. But I found an easier way:
LV.Items.RemoveAt(LV.Items.IndexOf(LV.SelectedItems(0)))
By now, this seems to work.
Best regards
Thomas
|
By Edhy Rijo - 12/21/2015
Hi Thomas,
Glad you had it working.
|
|