none
Reduce screen flicker in flowlayoutpanel RRS feed

  • Question

  • I have a number of controls in a flowlayoutpanel that are being created/deleted and recreated over time.  This is producing a visible flicker when the delete/recreate routine runs.  I have set the parent form to DoubleBuffered but there doesn't appear to be a similar setting for the flowlayoutpanel.

    Is there a way to reduce screen flicker when dynamically changing the contents of a flowlayoutpanel - or are there better containers I should use?

    Tuesday, October 16, 2018 8:24 PM

All replies

  • This works for a panel maybe it will work for flowlayoutpanel?

    See if this will work. You will need to replace the panel you have with this class, rebuild etc. I have not tried it.

    Public Class FlowEX
    
        Inherits FlowLayoutPanel
    
    
        Public Sub New()
    
    
            Me.DoubleBuffered = True
    
            SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer Or ControlStyles.ResizeRedraw Or ControlStyles.UserPaint, True)
    
            UpdateStyles()
    
    
        End Sub
    End Class

    Adapted from:

    http://vijirajkumar.blogspot.com/2010/04/double-buffering-with-panel-to-avoid.html

    PS What are you deleting/recreating and why and how? Maybe that needs to change?


    Tuesday, October 16, 2018 8:46 PM
  • It's chart controls - I actually started out trying to just change the dataview they used so they updated without me having to delete/recreate them but I couldn't get it working.  If I didn't recreate them each time, they didn't seem to get all the chart settings eg labels/colours etc.
    Wednesday, October 17, 2018 7:44 AM
  • It's chart controls - I actually started out trying to just change the dataview they used so they updated without me having to delete/recreate them but I couldn't get it working.  If I didn't recreate them each time, they didn't seem to get all the chart settings eg labels/colours etc.

    It seems you should not have to delete the chart control to get it to update if that is what you mean?

    Did you try chart.refresh?

    Or just clear the chart series and remake the series, don't delete the control.

    Is the dataview a binding source for chart?

    If you show a simple code example of how the chart is made and updated etc perhaps we will have ideas.

    Wednesday, October 17, 2018 9:15 AM
  • Thanks, there were some fundamental things I wasn't aware of that you've brought to bear - eg the effect of databind.
    Wednesday, October 24, 2018 9:23 PM