473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

How do I print MSChart controls?

I have an application that requires graphical output.
I have added a MSChart to the application and want to be
able to print this out. I have a form which allows me to
print, and zoom in etc for images loaded into its picture
box space and so I thought it would be a matter of copying
the graph object to the clipboard and then casting its
Metafile format to a bitmap which I could then use to fill
the picturebox. Not so, although during debugging I can
see that there is data present, and it seems that my cast
of the enhanced metafile object to bitmap was successful
(i.e. there were no exceptions thrown) my Bitmap seems to
be set to Nothing.

Any ideas??

Relevant code is provided below:
Sub BeginCopyPaste()
Dim MyBmp As Bitmap
AxMSChart1.EditCopy() 'copies MSChart object to clipboard

'Create a new instance of the DataObject interface.
Dim data As IDataObject = Clipboard.GetDataObject()
' If the data is picture, then set the cast
'to bitmap and assign to picturebox
If (data.GetDataPresent
(DataFormats.EnhancedMetafile)) Then

MyBmp = CType(data.GetData
(DataFormats.EnhancedMetafile), System.Drawing.Bitmap)
PictureBox1.Image = MyBmp
End If
AxMSChart1.Hide()
'CODE RETURNS TO FORM WITH FOCUS. I EXPECTED TO SEE A
GRAPH IN A PICTURE BOX BUT SEE NOTHING
End Sub
Nov 20 '05 #1
2 3375
One idea, but you're not going to like it !!

Obtain a colour photocopier and rest the monitor displaying the chart on top
face down. Press the start button on the copier and hey presto, colour
prints of your chart !

Sorry, I'm feeling very stupid and just could not resist that .
Regards - OHM
ROTFLMAO

andrew wrote:
I have an application that requires graphical output.
I have added a MSChart to the application and want to be
able to print this out. I have a form which allows me to
print, and zoom in etc for images loaded into its picture
box space and so I thought it would be a matter of copying
the graph object to the clipboard and then casting its
Metafile format to a bitmap which I could then use to fill
the picturebox. Not so, although during debugging I can
see that there is data present, and it seems that my cast
of the enhanced metafile object to bitmap was successful
(i.e. there were no exceptions thrown) my Bitmap seems to
be set to Nothing.

Any ideas??

Relevant code is provided below:
Sub BeginCopyPaste()
Dim MyBmp As Bitmap
AxMSChart1.EditCopy() 'copies MSChart object to clipboard

'Create a new instance of the DataObject interface.
Dim data As IDataObject = Clipboard.GetDataObject()
' If the data is picture, then set the cast
'to bitmap and assign to picturebox
If (data.GetDataPresent
(DataFormats.EnhancedMetafile)) Then

MyBmp = CType(data.GetData
(DataFormats.EnhancedMetafile), System.Drawing.Bitmap)
PictureBox1.Image = MyBmp
End If
AxMSChart1.Hide()
'CODE RETURNS TO FORM WITH FOCUS. I EXPECTED TO SEE A
GRAPH IN A PICTURE BOX BUT SEE NOTHING
End Sub


Best Regards - OHMBest Regards - OHM On**********@BTInternet.Com
Nov 20 '05 #2
* "andrew" <an*******@discussions.microsoft.com> scripsit:
Relevant code is provided below:
Sub BeginCopyPaste()
Dim MyBmp As Bitmap
AxMSChart1.EditCopy() 'copies MSChart object to clipboard

'Create a new instance of the DataObject interface.
Dim data As IDataObject = Clipboard.GetDataObject()
' If the data is picture, then set the cast
'to bitmap and assign to picturebox
If (data.GetDataPresent
(DataFormats.EnhancedMetafile)) Then

MyBmp = CType(data.GetData
(DataFormats.EnhancedMetafile), System.Drawing.Bitmap)
What if you cast to 'System.Drawing.Image'?
PictureBox1.Image = MyBmp
End If
AxMSChart1.Hide()
'CODE RETURNS TO FORM WITH FOCUS. I EXPECTED TO SEE A
GRAPH IN A PICTURE BOX BUT SEE NOTHING
End Sub


--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: arc | last post by:
My web application is using MSChart for reporting. (until i port it to some decent reporting tool) How to make sure all the web clients (IE atleast) have MSChart on their system to view these...
1
by: Jaime Lucci | last post by:
Has anybody any documentation about MSChart? Thanks.
1
by: perspolis | last post by:
Hi all I want to print content of a MsChart.. I think I can do that by getting an image from that.. How can I do that?or is there any better way to print MsChart? thanks in advance
5
by: Richard | last post by:
I don't know any thing about c#, I really need to do this in visual c++. I don't manually wrap the dll but since it's called AxInterop.OWC10.dll I assume visual studio has done that for me. ...
2
by: John Blair | last post by:
Hi, In my webform HTML i have the following code, but i cannot view and configure this chart control in the code behind class. In the code behind class i have a reference to this com control...
1
by: M Murschell | last post by:
In VB.Net, I have a DataSet called DataSet11, with some data that I want to chart. It has two fields, Month and EmployeeCount. I added a MSChart (Microsoft Chart Control 6.0). How do I get the...
0
by: clashway | last post by:
It took me so long to figure this out, I thought I would share it. This prints an MSChart using the metafilepict format after copying the chart to the clipboard. This provides a high-resolution...
0
debasisdas
by: debasisdas | last post by:
Here's a simple VB6 code snippet that uses the MSChart control to display Charts in VB6.0. To use this sample, please following steps Create a new project in VB6 Pull down the Project menu and...
0
by: Just_a_fan | last post by:
Some folks have searched, from time to time, for a dual axis MSChart with different scales on the two Y axes. The sample, extracted from running code I wrote, produces a graph with MSChart (VB9)...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.