Chart update with Button event in VB.NET

  • Thread starter Thread starter BreakItFixIt
  • Start date Start date
B

BreakItFixIt

Guest
Hi ,

I have following code inside button to plot a chart based of dropdownlist selection . It works the first time selection and won't update after different selection and button click event.


Dim strConn AsString="Data Source=BKKSQL001\INSTANCE01;"& _
"Initial Catalog=Northwind;Integrated Security=True"Dim conn AsNew SqlConnection(strConn)Dim sqlProducts AsString="SELECT Top 8 ProductName, UnitsInStock FROM Products"Dim da AsNew SqlDataAdapter(sqlProducts, conn)Dim ds AsNew DataSet()
da.Fill(ds, "Products")Dim ChartArea1 As ChartArea =New ChartArea()Dim Legend1 As Legend =New Legend()Dim Series1 As Series =New Series()Dim Chart1 =New Chart()Me.Controls.Add(Chart1)

ChartArea1.Name="ChartArea1"
Chart1.ChartAreas.Add(ChartArea1)
Legend1.Name="Legend1"
Chart1.Legends.Add(Legend1)
Chart1.Location=New System.Drawing.Point(13, 13)
Chart1.Name="Chart1"
Series1.ChartArea="ChartArea1"
Series1.Legend="Legend1"
Series1.Name="Series1"
Chart1.Series.Add(Series1)
Chart1.Size=New System.Drawing.Size(800, 400)
Chart1.TabIndex=0
Chart1.Text="Chart1"

Chart1.Series("Series1").XValueMember="ProductName"
Chart1.Series("Series1").YValueMembers="UnitsInStock"

Chart1.DataSource= ds.Tables("Products")


Please kindly help















Continue reading...
 
Back
Top