【问题标题】:Refresh DataGridView using BindingSource and TableAdapter使用 BindingSource 和 TableAdapter 刷新 DataGridView
【发布时间】:2015-11-04 18:25:40
【问题描述】:

我实际上是在 Customer-DataGrid 上工作,但我坚持使用 Sources,因为我不经常使用 C#。

我有一个 DataGridView (dataGridView1)、一个内部数据库 (Database.mdf)、一个 BindingSource (customerBindingSource) 和 customerTableAdapter

现在我尝试在单击按钮时刷新数据源。 这是一个简单的sn-p:

    private void Kundenverwaltung_Load(object sender, EventArgs e)
    {
        // TODO: This line of code loads data into the 'kundenAnsicht.customer' table. You can move, or remove it, as needed.
        this.customerTableAdapter.Fill(this.kundenAnsicht.customer);
    }

    // I tried already some methods but i dont find a properly, functionally way
    private void button2_Click(object sender, EventArgs e)
    {
        this.customerTableAdapter.Fill(this.kundenAnsicht.customer);
    }

我希望你能理解我的问题。 〜丹尼斯

【问题讨论】:

    标签: c# database datagridview datasource


    【解决方案1】:

    您需要将 DataGridView 与“customerBindingSource”连接:

    `private void Kundenverwaltung_Load(object sender, EventArgs e)
    {
        this.dataGridView1.DataSource = this.customerBindingSource;
        this.customerTableAdapter.Fill(this.kundenAnsicht.customer);
    }
    
    private void button2_Click(object sender, EventArgs e)
    {
        this.customerTableAdapter.Fill(this.kundenAnsicht.customer);
    }`
    

    这一切。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-24
      • 1970-01-01
      • 1970-01-01
      • 2013-12-21
      相关资源
      最近更新 更多