其实楼主根本没研究20楼的代码,只是抄写罢了
改为这样合理点:
Dim tab1 As WinForm.TabControl
Dim str As String
Dim pan As WinForm.Panel
Dim fnt As new Font("微软雅黑",10,FontStyle.Regular)
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim drs As List(of DataRow)
tab1 = e.Form.CreateControl("tab1", ControlTypeEnum.TabControl)
tab1.Dock = System.Windows.Forms.DockStyle.fill
tab1.Multiline=True
tab1.Font=fnt
e.Form.Controls("Panel1").addcontrol(tab1)
e.Form.Controls("tab1").basecontrol.ItemSize=new Size(60,25)
For Each str In DataTables("汽车销售").GetValues("品牌","品牌 Is Not Null")
tab1.TabPages.Add(str,str)
pan = e.Form.CreateControl("pan" & str, ControlTypeEnum.panel)
pan.Dock = System.Windows.Forms.DockStyle.fill
pan.AutoScroll=True
pan.BackColor = color.Silver
e.Form.Controls("tab1").basecontrol.tabpages(str).addcontrol(pan)
chart=e.Form.CreateControl("chart" & str, ControlTypeEnum.Chart)
e.Form.Controls("pan" & str).AddControl(Chart)
Chart= e.Form.Controls("Chart" & str) ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
drs =DataTables("汽车销售").Select("品牌 = '" & str & "'")
For Each dr As DataRow In drs
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = dr("月份") & "(" & dr("车型") & ")" '设置图系的标题
Series.Y(0) = dr("销量") '指定值
Series.DataLabelText = str & dr("车型") & " " & dr("月份") & "月销量为:" & dr("销量")
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East
Chart.Dock = System.Windows.Forms.DockStyle.fill
Next
e.Form.baseform.WindowState=2