【问题标题】:RadGridView not immediately updating DataSource when value is changed值更改时,RadGridView 不会立即更新 DataSource
【发布时间】:2013-10-11 23:23:41
【问题描述】:

我将 Telerik 的 RadControls for WinForms 用于我的 RadGridView 组件,并且我将其 DataSource 设置为 Extra(自定义对象)列表:

BindingList<Extra> extras;

在刷新 RadGridView 的 DataSource 的函数中:

var source = new BindingSource(extras, null);
extraGridView.DataSource = typeof(List<Extra>);
extraGridView.DataSource = source;

我已经在我的初始化程序中初始化了附加列表,我所拥有的一切都可以正常工作,除了一件事 - 当我的 RadGridView 单元格中的值发生更改时,即复选框,单击后该值不会立即更新,我需要再次单击以获得所需的结果。

我尝试通过 INotifyPropertyChanged 和 INotifyPropertyChanging 扩展我的 Extra 类,并在值更新时调用事件,但没有成功。我也尝试为 RadGridView 对象调用几个相关事件,但似乎没有任何效果。我也尝试为 BindingList 调用 ListChanged 事件。

除非我单击 RadGridView 上的其他位置,否则这些事件都不起作用;就好像列表实际上并没有改变一样......这个问题已经困扰了我 4 个小时的大部分时间,但无济于事。

【问题讨论】:

    标签: c# list datagridview datasource radgridview


    【解决方案1】:

    这也是我的问题。 我在这里找到了答案 http://www.telerik.com/forums/gridview-value-change

    我加了

    this.radGridView1.GridElement.Update(GridUINotifyAction.DataChanged);
    
    // or (when the code above doesn't help)
    
    this.radGridView1.MasterGridViewTemplate.Update(GridUINotifyAction.Reset);
    

    到我的 RadGridView ValueChanged 事件,它起作用了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-14
      • 2018-11-08
      • 1970-01-01
      • 2022-09-28
      • 2021-12-25
      • 2015-11-12
      • 2012-09-22
      • 1970-01-01
      相关资源
      最近更新 更多