我给mschart控件加入了百分比显示,但是在柱形图和饼形图来回切换时出错。我的代码如下,请问错在哪里?
private void button1_Click(object sender, System.EventArgs e)
{


         axMSChart1.ColumnCount = 5;
         axMSChart1.RowCount = 1; for (short i=1;i<=axMSChart1.ColumnCount;i++)
{
axMSChart1.Column = i;
axMSChart1.Row = 1;
axMSChart1.Data = i*10;
axMSChart1.ColumnLabel = String.Format("{0}", (i+1)*10);
} axMSChart1.chartType = MSChart20Lib.VtChChartType.VtChChartType2dPie;
int cnt = axMSChart1.Plot.SeriesCollection.Count();
for (short i=1; i<=cnt;i++)
{
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.LocationType = MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeInside ;
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.Component = (short)MSChart20Lib.VtChLabelComponent.VtChLabelComponentPercent;
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.PercentFormat = "0%";
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.VtFont.Size = 13;
}
}private void button2_Click(object sender, System.EventArgs e)
{
axMSChart1.ColumnCount = 1;
axMSChart1.RowCount = 5;

axMSChart1.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar;
for (short i=1;i<=axMSChart1.RowCount;i++)
{
axMSChart1.Row = i;
axMSChart1.Column = 1;
axMSChart1.Data = String.Format("{0}", (i+1)*10);
}
axMSChart1.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar;
for (short i=1; i<=axMSChart1.Plot.SeriesCollection.Count();i++)
{
         axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.LocationType =           MSChart20Lib.VtChLabelLocationType.VtChLabelLocationTypeInside ;
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.Component = (short)MSChart20Lib.VtChLabelComponent.VtChLabelComponentValue;
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.PercentFormat = "0%";
axMSChart1.Plot.SeriesCollection[i].DataPoints[-1].DataPointLabel.VtFont.Size = 13;
}
            
}