SharpDevelop,如何添加数据源?

发布于 2024-07-14 09:05:36 字数 153 浏览 2 评论 0原文

我正在尝试完成 C# 作业课程。 我应该将数据源添加到数据网格视图控件。 然而,在Sharp Develop中,通用任务菜单下的数据源对话框无法添加数据源。

这显然与 VS 的工作方式不同。 有人可以帮我弄清楚如何在 SharpDevelop 中执行此操作吗?

I am attempting to complete a homework lesson in C#. I am supposed to add a datasource to a Datagrid view control. However, in Sharp Develop under the common task menu the datasource dialog has no way to add a DataSource.

This apparently is different than how VS works. Can someone help me figure out how to do this in SharpDevelop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

分开我的手 2024-07-21 09:05:36

您可以使用显式绑定以编程方式添加数据源。 例如,在 FormLoad 事件期间(引入显式 BindingSource):

    private System.Windows.Forms.DataGridView dataGridView1;
    private System.Windows.Forms.BindingSource bindingSource1;
    private System.Data.DataSet dataSet1;
    private System.Windows.Forms.Label label1;
//...
    private void Form1_Load(object sender, EventArgs e)
    {
        this.dataSet1.ReadXml("x2.xml");
        this.label1.Text = dataSet1.Tables[0].TableName;
        this.bindingSource1.DataSource = dataSet1.Tables[0];
        this.dataGridView1.DataSource = bindingSource1;
    }

You can add the datasource programatically, using explicit binding. For example, during the FormLoad event (introducing an explicit BindingSource):

    private System.Windows.Forms.DataGridView dataGridView1;
    private System.Windows.Forms.BindingSource bindingSource1;
    private System.Data.DataSet dataSet1;
    private System.Windows.Forms.Label label1;
//...
    private void Form1_Load(object sender, EventArgs e)
    {
        this.dataSet1.ReadXml("x2.xml");
        this.label1.Text = dataSet1.Tables[0].TableName;
        this.bindingSource1.DataSource = dataSet1.Tables[0];
        this.dataGridView1.DataSource = bindingSource1;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文