反映新的约束力 [英] Reflecting new binding

查看:70
本文介绍了反映新的约束力的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

加载数据集已填充且数据源已设置为表格。

On Load the Dataset is filled and the datasource set to the table.

接下来在函数中另一个已过滤table in created并绑定到datagridview。

Next in a function another filtered table in created and bound to the datagridview.

但它只会更改视图,仍然单击它会打开旧行,前一个绑定索引。

But it only changes the view , still on click it opens the old row, previous binding index.

我还申请了

  dataGridView1.Update();

  dataGridView1.Refresh();

 dataGridView1.Update();
 dataGridView1.Refresh();

我还设置了

dataGridView1.DataSource = null;

dataGridView1.DataSource = null;

然后我绑定新表dataGridView1.DataSource = ds.Tables [0];

Then I bind new table dataGridView1.DataSource = ds.Tables[0];

但在给定的索引处,它仍会打开第一个绑定的旧行。

But at the given index it still opens the old row from the first binding.

问候。

请记住将答复标记为答案,如果他们提供帮助,如果他们没有提供任何帮助则取消标记,或者您可以投票一个有用的帖子

Please remember to mark the replies as answers if they help and unmark them if they provide no help , or you may vote-up a helpful post

推荐答案

尝试清除数据集然后重新将一些数据添加到数据集中:

Try to clear the dataset then re-add some data to the dataset:

        private DataTable dt = new DataTable();
        private DataSet ds = new DataSet();

        private void button1_Click(object sender, EventArgs e)
        {
            ds.Clear();
            adapter.Fill(ds);//re-fill dataset yourself
            dt = ds.Tables[0];
            dataGridView1.DataSource = dt;
        }

问候,

Frankie


这篇关于反映新的约束力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆