A
andrew
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
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