Ticket Q323039
Visible to All Users

Refresh ListView

created 14 years ago

I have a ListView (Load_ListView) for my object 'Load'. When I -> double click a load in its ListView -> Make a change to the load in the detail view -> click 'Save and Close' I want to trigger a refresh of the Load_ListView. I also want to have the Load_ListView refresh automatically every 5 min even if the user doesn't edit a load.
How may I do this?
Thanks,
Chris

Show previous comments (1)

    Michael,
    I didn't describe my problem very accurately, Sorry about that…I have attached a sample project that should illustrate the issue.
    Run the app against the included db -> on the LoadDrop_ListView click the 'New' button -> A new 'Load' (not load drop) object detail view will be shown -> in the Load_DetailView there is a LoadDrop_LookupListView -> Click the new button to create a new load drop - Click save&close for the loaddrop -> click save&close for the load -> you will see that the newly created LoadDrop does NOT appear in the LoadDrop_ListView -> click 'refresh and the new LoadDrop will appear in the list.
    How can I make that refresh automatic on Save&Close of the Load?
    Thanks,
    Chris

    DevExpress Support Team 14 years ago

      Hi Chris,
      Thank you for the project. In your instance, DetailViewLinkController does not update the source list view because it contains objects of a different type. You should implement a controller for the Load detail view, establish a link to the source list view and update it when changes are committed.

      C#
      public class LoadDetailViewController : ViewController { public LoadDetailViewController() { TargetViewType = ViewType.DetailView; TargetObjectType = typeof(Load); } public ListView LinkedListView { get; set; } protected override void OnActivated() { base.OnActivated(); Application.ViewShown += new EventHandler<ViewShownEventArgs>(Application_ViewShown); View.ObjectSpace.Committed += new EventHandler(ObjectSpace_Committed); } protected override void OnDeactivated() { Application.ViewShown -= new EventHandler<ViewShownEventArgs>(Application_ViewShown); View.ObjectSpace.Committed -= new EventHandler(ObjectSpace_Committed); base.OnDeactivated(); } void Application_ViewShown(object sender, ViewShownEventArgs e) { if (e.TargetFrame != null && e.TargetFrame.View == this.View && e.SourceFrame != null && e.SourceFrame.View is ListView && e.SourceFrame.View.ObjectTypeInfo.IsAssignableFrom(XafTypesInfo.Instance.FindTypeInfo(typeof(LoadDrop)))) { LinkedListView = (ListView)e.SourceFrame.View; } } void ObjectSpace_Committed(object sender, EventArgs e) { if (LinkedListView == null) return; LinkedListView.ObjectSpace.Refresh(); } }

      Attached is a modified project. Please review it and let us know if this helps.
      Thanks,
      Michael.

        Michael,
        your code sample worked flawlessly. I have implemented the LoadDrop_ListView refresh on Load Save and auto LoadDrop_ListView refresh on timer tick as per the links you gave.
        Both these are working correctly and my issue is resolved.
        Thanks,
        Chris

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.