简体   繁体   中英

how to update the datasource of a chart in C# panel from another panel

I'm creating an application consisting of 1 form and several panels, which I stack on top of another panel so I can just call the panel.BringToFront() to show it.

My first panel consists of a chart whose datasource is from my database. So once I added or changed some data from my second panel, I need to update the chart in the first panel. What I've done is calling initializeChart() everytime I add or change something. The problem is my chart in the first panel is not updated. But when i try to update the table inside the same panel it works. Here is my initializeChart() code :

private void initializeChart()
{               
    chart1.DataSource = database.getMonthlyProfitList();
    chart1.Series["Income"].XValueMember = "Bulan";
    chart1.Series["Income"].YValueMembers = "Pendapatan";
}

So do you guys have any Idea why I can update the view on the same panel but not on other panel, and if that's possible how to do that?

Add the following line of code in the last:

private void initializeChart()
{               
    chart1.DataSource = database.getMonthlyProfitList();
    chart1.Series["Income"].XValueMember = "Bulan";
    chart1.Series["Income"].YValueMembers = "Pendapatan";
    chart1.DataBind();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM