StrataFrame Forum

MaintenanceFormToolStrip Uasge

http://forum.strataframe.net/Topic999.aspx

By franka - 4/28/2006

I have a SF form that I added a MaintenanceFormToolStrip to.  I want to use the maintenance buttons (New, Edit, Save, etc.) but not the naviagtion buttons which I have turned off.  Instead I want to use a ListView control for navigation.  Everything works fine except for the refreshing/updating of the listview.  How can I keep the listview in sync with the maintenance that is being performed?  Call the requery method on the listview?  At what point?

Thanks!!

By StrataFrame Team - 4/28/2006

You'll need to refresh the list view whenever the data within the business object changes. What I would do is add a handler to the AfterSave event of the business object on the form and call ListView.Requery() in there.



Within the list population, you might look at using the CopyDataFrom method for the business object rather than pulling the data from the database every time. If you do that, then you can Requery() the ListView as often as you want without worrying about roudtrips to the database. You'll be able to put a Requery() in the Navigated event and possibly even the FieldPropertyChanged event (you'll have to configure your business object to have changed events in the BOMapper and rebuild the partial class before you'll see that event on your business object).
By franka - 5/1/2006

Thanks Ben.  The requery works fine but I have another problem that I can't figure out and maybe you can help.  When I perform the requery I programatically select the item in the list I want highlighted.  That works fine.  But if the selected item is not within the viewable portion of the list, the scroll position is not chantged to allow the selected item to be in the display window.  How can I scroll the listview to insure the selected item is in the displayable portion of the control?  Here's my code:

Private Sub AttendingsBO_AfterSave(ByVal e As MicroFour.StrataFrame.Data.AfterSaveUndoEventArgs)   Handles AttendingsBO.AfterSave

Me.lvAttendings.Requery()

Dim strKey As String

Dim intX As Integer

strKey = Me.AttendingsBO.CurrentRow.Item("OPH_ID")

For intX = 0 To Me.lvAttendings.Items.Count - 1

If Me.lvAttendings.Items(intX).SubItems(1).Text = strKey Then

Me.lvAttendings.Items(intX).Selected = True

Me.lvAttendings.Select()

Exit For

End If

Next

End Sub

By StrataFrame Team - 5/1/2006

Hi Frank,



Glad that worked for you. To get the list view to scroll to that record, you need to put this line of code after you select the row:



Me.lvAttendings.EnsureVisible(intX)



Put that right before the Exit For, and the ListView will scroll to that record and make sure that it is visible.
By franka - 5/2/2006

Dahhh!!!  Don't know how I missed that property.  Thanks!!Doze
By StrataFrame Team - 5/2/2006

I didn't know it was there until Trent pointed it out one day Whistling