Search code examples
c#winformspie-chartmschart

pie chart is not refreshed until window state is changed


I am assigning datasource to pie chart on datetime picker value change in winform c# but data in chart is not refreshed until window state is changed by e.g. minimize or maximize. Why?

I am using chart control in visual studio. on datetime picker value change I am calling fillchart()

private void fillCharts()
{
    try
    {
        chartBookingConversion.DataSource = db.getData1(@"query", 
                            dateTimePicker_From.Value.Date, dateTimePicker_TO.Value.Date);
    }
    catch (Exception ex) { throw ex; }
}

Nothing else.


Solution

  • This is by design so you can have many changes without the chart (or other bound control) nervously flickering all the time. Imagine adding dozens or hundreds of data rows..

    Simply call the DataBind method (again) when you are done adding data!