Search code examples
c#datatabledoublebufferedtoolstripstatuslabel

Stop ToolStripStatusLabel from flickering due to amount of data from datatable


I've got a ToolStripStatusLabel with data loading in live, there is so much information coming through that it becomes unreadable.

Is there any double buffer function for this? I have tried the following:

public static void DoubleBufferedToolStripStatusLabel(this ToolStripStatusLabel tssl, bool setting)
{
     Type dgvType = tssl.GetType();
     PropertyInfo pi = dgvType.GetProperty("DoubleBuffered", 
     BindingFlags.Instance | BindingFlags.NonPublic);
     pi.SetValue(tssl, setting, null);
}

Solution

  • How about only updating it every second, rather than every time it needs updating?

    DateTime _lastUpdated = DateTime.MinValue;
    
    void UpdateStatusLabel(string text)
    {
        if(DateTime.Now > _lastUpdate)
        {
            ToolStripStatusLabel.Text = text;
            _lastUpdate = DateTime.Now + TimeSpan.FromSeconds(1);
        }
    }