4 Replies Latest reply on May 7, 2014 4:48 PM by seneschal

    AFTreeView flickering


      I am using the AFTreeView to display AFElements in an application.


      When I do some bulk updating of element data - say I am adding 1000 AFAttributes or something, which is done on a separate thread, the tree view flickers badly the entire time.  I even tried to minimize the number of checkins I do, but this does not help.


      Is there a way to prevent the tree from flickering? Or maybe I should be using some kind of bulk update method?



        • Re: AFTreeView flickering

          Wrap your code between calls to BeginUpdate and EndUpdate


          try { treeview.BeginUpdate(); /* your code to update tree*/ } finally { treeview.EndUpdate(); }

            • Re: AFTreeView flickering

              Thanks - but I already tried that, the result is that the tree goes completely blank during the operation. It does come back, but the blank tree would be disconcerting to a user.

                • Re: AFTreeView flickering

                  This could be due to events firing and the tree redrawing due to these events. There is a property on a PI system that allows you to enable (default) or disable events from AF objects within the PI system. The property name is EventsEnabled. PSE uses this flag during imports where large number of objects are added.


                  Generally you'll need to wrap your code in a try/finally statement and set the EventsEvabled to false in the try block and back to to true in the finally block. Of course, since no events are firing, you'll need to refresh your tree manually after enabling the events.


                  *** Warning: failure to enable the events will mean you'll no longer receive any events for the particular PI system. Also, any other controls you're using will also require a manual refresh.