【问题标题】:Prevent SelectionChanged on loading DataGridView在加载 DataGridView 时防止 SelectionChanged
【发布时间】:2020-01-21 20:27:00
【问题描述】:

我需要在不触发 SelectionChanged 事件的情况下加载 DataGridView。 似乎当它被加载时,它必须选择一个触发这个不需要的事件的单元格。 有没有办法绕过它?

【问题讨论】:

    标签: c# .net vb.net


    【解决方案1】:

    您可以在加载 DataGridView 时删除事件处理程序。

    private void LoadDataGridView()
    {
       TheDataGridView.SelectionChanged -= TheDataGridView_SelectionChanged; // Remove the handler.
       try
       {
          // Load the data grid view.
       }
       finally
       {
          TheDataGridView.SelectionChanged += TheDataGridView_SelectionChanged; // Add the handler back.
       }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-03
      • 2010-12-19
      相关资源
      最近更新 更多