【问题标题】:Drawig Graphics in Windows Forms Application C#在 Windows 窗体应用程序 C# 中绘制图形
【发布时间】:2017-05-20 23:49:45
【问题描述】:

大家好,我需要一些帮助才能在 Windows 窗体应用程序中绘制图形。

我从这里下载了 .NET Community Edition 的 Nevron Chart:

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

然后我从 Windows 窗体应用程序的工具中拖出一张图表

所以我在图表中与 MySql 建立连接,但我需要在图表中导出查询。

我的代码是:

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();
    }

我不确定我是否需要 foreach ?

我需要从

导出这个查询
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)";`

在图表中?

一些关于代码的帮助?

【问题讨论】:

  • 这个不清楚,你对dt3中的行做了什么?您需要在图表中导出查询,只是图表图形或SQL?你在哪里分配图表数据源?
  • 你能给我示例代码吗?
  • 这是我的数据库字符串,字符串 MyConString3 = "SERVER=localhost;" +“数据库=hydrodb;” + "UID=root;" + "密码=;";
  • 你的标题似乎很误导人。您正在寻找的只是将查询中的数据提供给 Nevron Chart,对吗?请更正标题和标签!
  • 大声笑老兄,我问了你 3 件事来澄清你的问题,你没有回答任何问题并回复 请给我 teh codez!

标签: c# mysql .net winforms


【解决方案1】:

如果您想在 winform 中绘制图形,为什么不使用 zedgraph 来代替。他们也有很多图表的示例代码..

请查看以下链接:

1. Samples From Code project

2. The Official Site containing sample materials

【讨论】:

  • 虽然这在理论上可以回答问题,it would be preferable 在这里包含答案的基本部分,并提供链接以供参考。
  • 我不喜欢 zedgraph :)
猜你喜欢
  • 1970-01-01
  • 2019-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-23
  • 1970-01-01
  • 2012-10-20
  • 1970-01-01
相关资源
最近更新 更多