反映新的约束力
加载数据集已填充且数据源已设置为表格。
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