【问题标题】:How to fix 'Key already exists Parameter name: Key' error in UltraGrid?如何修复 UltraGrid 中的“密钥已存在参数名称:密钥”错误?
【发布时间】:2019-05-23 02:25:25
【问题描述】:

我想在编码开始时将 Grid Column 设置为编码的 Grid InitializeLayout 事件。

UltraGridColumn ugc = null;

ugc = e.Layout.Bands[0].Columns.Add(key,caption);

ugc = e.Layout.Bands[0].Columns.Add(key2, caption2);
ugc.CellAppearance.TextHAlign = HAlign.Left;
ugc.Width = 190;
ugc.LockedWidth = true;

每次搜索时,我都尝试通过从数据库接收一个值作为 DataTable 来绑定到 Grid DataSource。

uGrid.DataSource = dt;

此代码导致错误。

密钥已存在参数名称:密钥

我不知道是什么导致了这个错误。我做错了什么?

【问题讨论】:

    标签: c# winforms infragistics


    【解决方案1】:

    在 InitializeLayout 事件中,在添加之前检查列是否存在。这样可以防止重复。 //像这样 if(!e.Layout.Bands[0].Columns.Exists("key")) e.Layout.Bands[0].Columns.Add(key,caption);

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-17
      • 2023-03-08
      • 2017-10-01
      • 2016-02-17
      • 1970-01-01
      • 2022-12-05
      • 2022-01-14
      • 1970-01-01
      相关资源
      最近更新 更多