BulletGraph for WinForms
画像へのエクスポート
BulletGraphの操作 > 画像へのエクスポート

The export option in a control helps you to save and store the screenshots of the control in various file formats. Since the BulletGraph control is a data visualization control, it can be exported to different image formats such as PNG, JPEG etc.

To export a BulletGraph control as an image, you can make use of the GetImage method of the C1BulletGraph class. This method returns an object of the type Image which is the screenshot of the BulletGraph control. You can optionally specify the height, width, and pixel format of the image to be returned using different overloads of this method.

Once you get the control’s image, you can use the Save method of the Image class to save the returned image.

The code below depicts how you can export the BulletGraph control to an image on the click of a button:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim dialog = New SaveFileDialog()
    dialog.Filter = "PNG|*.png|JPEG |*.jpeg"

    If dialog.ShowDialog() = DialogResult.OK Then
        Dim ext As String = dialog.FileName.Split("."c)(1)
        Dim bulletGraphImage As Image = C1BulletGraph1.GetImage()
        bulletGraphImage.Save(dialog.FileName)
    End If
End Sub
private void export_Click(object sender, EventArgs e)
{
    var dialog = new SaveFileDialog();
    dialog.Filter = "PNG|*.png|JPEG |*.jpeg";
    if (dialog.ShowDialog() == DialogResult.OK)
    {
        string ext = dialog.FileName.Split('.')[1];
        Image bulletGraphImage = c1BulletGraph1.GetImage();
        bulletGraphImage.Save(dialog.FileName);
    }
}