Generating and Saving ZedGraph plots without showing on forms

前端 未结 2 1520
北恋
北恋 2021-02-20 17:31

Is it possible to plot data on to a ZedGraph graph and save it as a file without showing / generating a graph that is visible to the user? I\'m looking to process a lot of datas

2条回答
  •  孤街浪徒
    2021-02-20 18:10

    It is possible.

    You create and manipulate the ZedGraph control as usual, but just don't add it to the Form.Controls list, for example, in the InitializeComponent() method, comment out something that looks like the below

    this.Controls.Add(this.zedGraphControl);
    

    There are a couple of ways to save the graph

    • If you want a SaveAs dialog to appear, call SaveAs() on the graph control.
    • If you don't want the dialog, you can write out the image using GetImage() on the MasterPane, and then save that:

      zedGraphControl.MasterPane.GetImage().Save("test.bmp");

提交回复
热议问题