[RESOLVED] Access to datagridview to datagridwiew to chart : almost there?
Hi,
I have an access database with two tables:
Table 1 holds equipment information (various columns)
Table 2 holds counter information for these equipments (running hours)
In my VB Form, I have a datagridview1 which shows the data from table 1 (the datasource is a bindingsource to a dataset)
I have a second datagridview2 which shows all the hour counter records for the selected equipment from table 1 (the datasource is bindingsource to another bindingsource here).
So far, everything works...
I placed a chart on the form, where the datasource is TableEquipmentTableCounterBindingSource.
The chart/series/datasource/XValueMember and YValueMembers are set to the columns I want to display, but the chart remains empty...
When I run it, and select another equipment in datagridview1, the second datagridview displays the appropriate hour counters for that equipment, bet the chart stays empty at all times...
Any Ideas?
Re: Access to datagridview to datagridwiew to chart : almost there?
Hi,
I bet you have forgotten to either set the DataSource of the Chart or call the Series.Invalidate Method to redraw your Chart when your values change? Here is a typical chart setup:-
vb.net Code:
With chtTotalOrders
With .ChartAreas(0)
.AxisX.Interval = 2
.AxisX.LabelStyle.Interval = 1
.Area3DStyle.Enable3D = True
End With
With .Series(0)
.ChartType = DataVisualization.Charting.SeriesChartType.Column
.XValueType = DataVisualization.Charting.ChartValueType.Date
.XValueMember = "OrderDate"
.YValueMembers = "TotalOrders"
.LegendText = "Total Orders Received"
End With
.Legends(0).Docking = DataVisualization.Charting.Docking.Top
End With
And here is a typical chart redraw when values change:-
vb.net Code:
With chtTotalOrders
.DataSource = currentAnalysis
.Series.Invalidate()
End With
Hope that helps.
Cheers,
Ian
Re: Access to datagridview to datagridwiew to chart : almost there?
Hi Ian,
thank you for your reply to my post.
After starting this thread , I googled some more on this topic, and found out I had to call the DataBind method before updating the chart.
Code:
Chart1.DataBind()
Chart1.Update()
This solved the problem. I was curious and tried your solution also, but that didn't work:
Code:
Chart1.Series.Invalidate()
Chart1.Update()
Am I doing it wrong? What does "Invalidate" do? I would expect there would also exist a "validate", but that doesn't seem to be the case...
Re: [RESOLVED] Access to datagridview to datagridwiew to chart : almost there?
Hi,
Glad you got it sorted. I have never actually had a DataBind issue but I have come across a Chart not Redrawing when required and the Invalidate Method causes a Redraw of the Graphics of the Chart. Have a look here:-
Chart.Invalidate Method
Cheers,
Ian