.net {"已添加项。字典中的关键字:“**”所添加的关键字:“**”"}

来源:互联网 发布:传奇物品数据库文件名 编辑:程序博客网 时间:2024/05/21 11:27
用户代码未处理 System.ArgumentException
  HResult=-2147024809
  Message=已添加项。字典中的关键字:“00”所添加的关键字:“00”
  Source=mscorlib
  StackTrace:
       在 System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
       在 System.Collections.Hashtable.Add(Object key, Object value)
       在 DevExpress.XtraTreeList.Data.TreeListBoundData.CreateAllNodes()
       在 DevExpress.XtraTreeList.Data.TreeListBoundData.CreateNodes(TreeListNode parent)
       在 DevExpress.XtraTreeList.TreeList.LoadNodes()
       在 DevExpress.XtraTreeList.TreeList.DoDataSourceChanged()
       在 DevExpress.XtraTreeList.TreeList.UpdateDataSource(Boolean updateContent)
       在 DevExpress.XtraTreeList.TreeList.UpdateDataSourceOnChangeDataSource()
       在 DevExpress.XtraTreeList.TreeList.set_DataSource(Object value)
       ...

  InnerException:


原因:

DataTable类型数据wlTable的列xtnbdm有重复数据"00",而TreeList.KeyFieldName对应值应该非重复.

DevExpress.XtraTreeList.TreeList treewl;

treewl.DataSource = wlTable;

this.treewl.KeyFieldName = "xtnbdm";

//
// 摘要:
//     Gets or sets a value specifying the key field of the data source bound to
//     the XtraTreeList control.
[XtraSerializableProperty]
[DevExpressXtraTreeListLocalizedDescription("TreeListKeyFieldName")]
[Category("Data")]
[DefaultValue("ID")]
[TypeConverter("DevExpress.XtraTreeList.Design.TypeConverters.FieldNameTypeConverter, DevExpress.XtraTreeList.v13.2.Design")]
public string KeyFieldName { get; set; }

解决:

去掉重复数据


0 0
原创粉丝点击