VS 2013 [RESOLVED] Access to datagridview to datagridwiew to chart : almost there?-VBForums
Results 1 to 4 of 4

Thread: [RESOLVED] Access to datagridview to datagridwiew to chart : almost there?

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    49

    Resolved [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?

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,230

    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:
    1. With chtTotalOrders
    2.   With .ChartAreas(0)
    3.     .AxisX.Interval = 2
    4.     .AxisX.LabelStyle.Interval = 1
    5.     .Area3DStyle.Enable3D = True
    6.   End With
    7.   With .Series(0)
    8.     .ChartType = DataVisualization.Charting.SeriesChartType.Column
    9.     .XValueType = DataVisualization.Charting.ChartValueType.Date
    10.     .XValueMember = "OrderDate"
    11.     .YValueMembers = "TotalOrders"
    12.     .LegendText = "Total Orders Received"
    13.   End With
    14.   .Legends(0).Docking = DataVisualization.Charting.Docking.Top
    15. End With

    And here is a typical chart redraw when values change:-
    vb.net Code:
    1. With chtTotalOrders
    2.   .DataSource = currentAnalysis
    3.   .Series.Invalidate()
    4. End With

    Hope that helps.

    Cheers,

    Ian

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2012
    Posts
    49

    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...

  4. #4
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,230

    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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.