1

我在使用 DataGridViewComboBoxColumn 更新 DataGridView 时遇到问题。当我设置 DataGridViewComboBoxColumnCell 的值时,它可以工作,但 UI 没有刷新。

我在控件上尝试了 Invalidate()、Refresh()。给它焦点,然后将焦点切换到另一个控件。当我在按钮事件中使用相同的循环时,它正在工作。

到目前为止我的代码:

        BindingList<String> list = new BindingList<String>();
        list.Add("Value1");
        list.Add("Value2");

        DataTable table = new DataTable();
        DataColumn col = table.Columns.Add();
        col.ColumnName = "Key";
        col.DataType = typeof(String);

        dataGridView1.DataSource = table;
        table.Rows.Add("Key1");
        table.Rows.Add("Key2");

        DataGridViewComboBoxColumn combo = new DataGridViewComboBoxColumn();
        combo.DataSource = list;
        combo.Name = "Value";
        dataGridView1.Columns.Add(combo);

        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            row.Cells["Value"].Value = "Value1";
        }

我对两个 ZedGraphControls 有类似的行为。我实现了依赖缩放,并且仅当我第一次在两个控件中手动缩放时,绘图中的比例才发生变化。在我的 DataGridView 中也会发生同样的情况,例如当我手动更改列宽并再次调用该方法时,UI 会被刷新。

4

0 回答 0