Sync ListView with PrimaryBusinessObject on Maintenance Form


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I'm glad that got you going!  We are in fact going to be at TechEd Boston in June.  We will also be in Orlando DevConnections April 2-5. 

I too am glad you stopped by the booth and I am glad to see you putting the framework to good use.  If you are going to be at either of the shows I just mentioned, please let me know and definitely look me up.  I would love to say, "Hello" in person!

Tom Wilkinson
Tom Wilkinson
StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)
Group: Forum Members
Posts: 4, Visits: 48
Thanks Trent.  I worked. 

I am glad I visited you booth at the ASP.NET conference in Las Vegas last year.  Are any of you going to TechEd this year?

Thanks

Tom Wilkinson

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You will need to place the code in the Navigated event of the business object to reposition the index of the listview.  If you use the primary key value as the "Tag Mamber" in the PopulationDataSourceSettings of the listview population, then the PK will exist for each record (or row) in the Tag property.  So your code may look something like this:

    ''' <summary>

    ''' Capture the navigated event to sync up the listview

    ''' </summary>

    ''' <param name="e"></param>

    ''' <remarks></remarks>

    Private Sub Customers_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles Customers.Navigated

        SetListViewIndex(Customers.cust_pk)

    End Sub

 

    ''' <summary>

    ''' Syncs the listview with a primary key

    ''' </summary>

    ''' <param name="PrimaryKey"></param>

    ''' <remarks></remarks>

    Private Sub SetListViewIndex(ByVal PrimaryKey As Integer)

        '-- Esatblish Locals

        Dim loItem As ListViewItem

 

        '-- Remove any selected items

        For Each loItem In Me.ListView1.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

                ListView1.EnsureVisible(ListView1.Items.IndexOf(loItem))

            Else

                '-- Turn off the selection

                loItem.Selected = False

            End If

        Next

    End Sub

Obviously you can modify this to fit your needs, but this should give you the general idea.

Tom Wilkinson
Tom Wilkinson
StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)
Group: Forum Members
Posts: 4, Visits: 48
Thanks, Trent that worked.

Is there a way I can programmatically change the listview selection when the BusinessObject is navigated through the toolstrip?

I would like to change the listview selection to whatever the current record is if the users use the next or previous button and deletes or adds a record.

Tom Wilkinson

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
When populating a listview an internal instance of the BO is dynamically created.  Even if you use the CopyDataFrom method, it is using the internal BO of the listview to populate itself.  To navigate a specific instance of a BO to another record place the following code in the SelectedIndexChanged event of the listview:

If MyListView.SelectedItems.Count > 0
    FormInstanceBO.NavigateToPrimaryKey(CType(MyListView.SelectedItem(0).Tag, Integer))
End If

Obviously you will need to make any necessary changes to match your PK value. 


Tom Wilkinson
Tom Wilkinson
StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)StrataFrame Beginner (4 reputation)
Group: Forum Members
Posts: 4, Visits: 48
I am trying to setup a ListView that will let a user navigate to the record to change.  I want a single selection to change the PrimaryBusinessObject (PBO) to that same record.  I also want the navigation buttons changes to change the selected record in the listview. 

I think I can use the Navigated event on the PBO but I don't know how to tell the listview to change selection.  I know I can use PBO.Navigate to move the PBO but I don't know when a what to look for in the listview.

Any doc on the listview would be appreciated.  I usualy code in C# but since your tutorial is in VB I am giving VB a try.  I heard a couple of well known .NET speakers say we all should know both languages, each has its advantages Smile

Thanks.

Tom Wilkinson

Cuyahoga Community College


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