private void btnKind_Click(object sender, EventArgs e) { string strbtnName = ((Button)sender).Name.ToString(); switch (strbtnName) { case "btnKind1": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dLine; break; case "btnKind2": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dLine; break; case "btnKind3": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dBar; break; case "btnKind4": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar; break; case "btnKind5": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dPie; break; case "btnKind6": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dStep; break; case "btnKind7": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dStep; break; } }希望对你有帮助
Button[] btns = new Button[9];//点击 按钮 for ( int i = 0; i<9; i++) { btns[i] = new Button(); btns[i].Location = new System.Drawing.Point(100,100); btns[i].Name = ""; btns[i].Size = new System.Drawing.Size(48,48); btns[i].Text = i.toString(); btns[i].Click += new System.EventHandle(this.btns.Click) this.Controls.Add(btns[i]); }
{
string strbtnName = ((Button)sender).Name.ToString();
switch (strbtnName)
{
case "btnKind1": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dLine; break;
case "btnKind2": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dLine; break;
case "btnKind3": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dBar; break;
case "btnKind4": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dBar; break;
case "btnKind5": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dPie; break;
case "btnKind6": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType2dStep; break;
case "btnKind7": axMSChart.chartType = MSChart20Lib.VtChChartType.VtChChartType3dStep; break;
}
}希望对你有帮助
for ( int i = 0; i<9; i++)
{
btns[i] = new Button();
btns[i].Location = new System.Drawing.Point(100,100);
btns[i].Name = "";
btns[i].Size = new System.Drawing.Size(48,48);
btns[i].Text = i.toString();
btns[i].Click += new System.EventHandle(this.btns.Click)
this.Controls.Add(btns[i]);
}