我使用MSchart控件显示了图表,可是没有发现里面有保存图片的函数,请问怎样保存显示了图表为图片呢!

解决方案 »

  1.   

    Dim strsavefile As String
        With dlgSaveAs
            .Filter = "Pictures (*.bmp)|*.bmp"
            .DefaultExt = "bmp"
            .CancelError = True
            .ShowSave
            strsavefile = .FileName
            If strsavefile = "" Then Exit Sub
        End With
        
        MSChart1.EditCopy
        SavePicture Clipboard.GetData, strsavefile
    Exit Sub
    我用vb6.0 写过,但C#不知道怎么写。呵呵。希望对你能有帮助,也希望各位高手给个C#的
      

  2.   

    参看
    http://www.codeproject.com/csharp/capture_and_print_mschart.asp
      

  3.   

    正好刚写的给你:
    public static bool SaveClipboardBMPToFile()
    {
    try
    {
    IDataObject iData = System.Windows.Forms.Clipboard.GetDataObject();
    if(iData == null)
    return false;
    System.Drawing.Image im = (System.Drawing.Image)iData.GetData(DataFormats.Bitmap);
    if(im == null)
    return false;
    System.Windows.Forms.SaveFileDialog sfd = new SaveFileDialog();
    sfd.Filter = "BMP文件|*.bmp|JPEG文件|*.jpg";
    if(sfd.ShowDialog() == DialogResult.OK)
    {
    if(sfd.FilterIndex == 1)
    im.Save(sfd.FileName,System.Drawing.Imaging.ImageFormat.Bmp);
    else
    im.Save(sfd.FileName,System.Drawing.Imaging.ImageFormat.Jpeg); }
    return true;
    }
    catch
    {
    return false;
    }
    }
    调用:
    cht_Analyse.EditCopy() ;
    if( !epbsTool.SaveClipboardBMPToFile() )
    MessageBox.Show(this,"导出图像失败!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);