简体   繁体   English

在 Windows 窗体应用程序 C# 中绘制图形

[英]Drawig Graphics in Windows Forms Application C#

Hello guys I need some help to draw the graphic in Windows Forms Application.大家好,我需要一些帮助来在 Windows 窗体应用程序中绘制图形。

I downloaded Nevron Chart for .NET Community Edition from here:我从这里下载了 Nevron Chart for .NET Community Edition:

https://www.nevron.com/products-dot-net-chart-free-control https://www.nevron.com/products-dot-net-chart-free-control

And I drag one chart from tools in Windows Forms Application我从 Windows 窗体应用程序中的工具中拖出一张图表

So I make connection in the chart with MySql but I need to export the query in the chart.所以我在图表中与 MySql 建立连接,但我需要在图表中导出查询。

My Code is:我的代码是:

private void chart1_Click(object sender, EventArgs e) {
    string MyConString3 = "SERVER=localhost;" + "DATABASE=hydrodb;" +
                "UID=root;" + "PASSWORD=;";
    MySqlConnection connection3 = new MySqlConnection(MyConString3);

    string command3 = "select year(Dat),month(Dat),min(vkolmin),avg(Vkolsre),Max(Vkolmax) from hydmes where station='"
        + comboBox1.SelectedItem.ToString() + "' and Dat between '"
        + comboBox2.SelectedItem.ToString() + "' and '" + comboBox3.SelectedItem.ToString()
        + "' group by year(dat),month(Dat)";
        MySqlDataAdapter da3 = new MySqlDataAdapter(command3, connection3);
        DataTable dt3 = new DataTable();
        da3.Fill(dt3);

        string s = "";
        foreach (DataRow row in dt3.Rows) {
            string rowz = string.Format("{0}, {1}, {2}, {3}, {4}", row.ItemArray[0], row.ItemArray[1], row.ItemArray[2],
            row.ItemArray[3], row.ItemArray[4]);
            s += "-" + rowz;
        }
        connection3.Close();
    }

I'm not sure if I need foreach ?我不确定是否需要 foreach ?

I need to export this query from我需要从

string command3 = "select year(Dat),month(Dat),min(vkolmin),avg(Vkolsre),Max(Vkolmax) from hydmes where station='"
    + comboBox1.SelectedItem.ToString() + "' and Dat between '"
    + comboBox2.SelectedItem.ToString() + "' and '" + comboBox3.SelectedItem.ToString()
    + "' group by year(dat),month(Dat)";`

In the chart ?在图表中 ?

Some help with the code ?一些帮助代码?

If you wish to draw graphics in winform, why not use the zedgraph instead.如果您想在 winform 中绘制图形,为什么不改用 zedgraph。 They have got lots of sample codes for many varieties of charts as well..他们还为各种图表提供了大量示例代码。

Do checkout the following links :请查看以下链接:

1. Samples From Code project 1. 来自代码项目的示例

2. The Official Site containing sample materials 2. 包含样品材料的官方网站

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM