Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

How to requery a MS Office Chart

 

I have put a Com-component 'Microsoft Office Chart 10.0' on my VB.Net form. It gets its data from a Datamember (a query in an Access Database).

How do I perform a requery in .Net-coding for this Chart (there is a right-click on the chart that does the renewal of the data, but I don't want to use that for my users). I don't find any helpful information on MS of the helpfiles.

There is a Chart1.refresh option, but that does nothing.

 

Anyone more information?

 

Thanks,

Paul

Edited by PaulZ
Posted (edited)

I would try to make use of the help files on it. I have not gone through it a lot, but I did dig up the following example:

Set c = ChartSpace1.Constants
Set ChartSpace1.DataSource = Spreadsheet1.Object
ChartSpace1.Charts.Add
ChartSpace1.Charts(0).Type = c.chChartTypeLineMarkers
ChartSpace1.Charts(0).SetData c.chDimCategories, 0, "a2:a28"
ChartSpace1.Charts(0).SetData c.chDimSeriesNames, 0, "b1"
ChartSpace1.Charts(0).SeriesCollection(0).SetData c.chDimValues, 0, "b2:b28"

The code is VB6/VBA code, but it's the same idea. In that above example, it seems that the data is "bound" to an Excel spreadsheet. (The "b2:28" stuff.) I would think that there would be other ways to get data in there, but worst case this suggests that you could use Excel as the data source. However, if Excel is not already open, then I guess this would be quite a bit of extra overhead for just a Chart...

 

Ok, the help file for DataSource states: "Returns or sets the ADO DataSource object that represents the data source for the specified control." So the above example is just for when an Excel Worksheet is the ADO data source. You should be able to change/refresh your ADO settings by updating these values I would think.

Edited by Mike_R

Posting Guidelines

 

Avatar by Lebb

  • 2 weeks later...
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...