2017-02-09 5 views
2

Telerik Treeview 컨트롤이 있는데 항목 1 개를 제거하지 못했을 때 RemoveAt(0)에 문제가 추가되었습니다. 어떻게 이것이 가능할 수 있습니까?
Collection<T>가있다 (속성 변경 인터페이스 통지로)컬렉션에 대한 RemoveAt가 실패합니다.

- ParentNode 
    |- child1 
    |- child2 

TreeViewNode.Nodes는이 RadTreeNodeCollection 객체
RadTreeNodeCollectionNotifyCollection<RadTreeNode>
NotifyCollection<T>Collection<T> 임 : 여기

제가 가지고있는 예이다 기본 Microsoft 모음

그래서 이것은 무슨 일이 일어나고 있는지 설명하기 위해 샘플 :

// get parent node called "ParentNode" result is not null 
var parentNode = treeview1.Nodes[0]; 

// get quantity of nodes result is 2 
var qtyNodes = parentNode.Nodes.Count; 

// try removing the first node : this calls Collection<T>.RemoveAt(T); 
parentNode.Nodes.RemoveAt(0); 

// here count is still 2 

// removing the tag from the node which contain model informations 
parentNode.Nodes[0].Tag = null; 

// try removing the first node again 
parentNode.Nodes.RemoveAt(0); 

// now the count is 1 so the item really got removed 

태그는 Collection.RemoveAt()와 함께 무엇을해야합니까? 또한 노드에서 태그를 제거해도 작동하지 않는 또 다른 경우가 있습니다. 그렇다면 객체의 다른 속성으로 인해 Collection.RemoveAt이 실패 할 수 있습니까?

* 나는 단순히 표준 Microsoft TreeViewTreeNode에 의해 (TreeNode telerik) 모든 RadTreeView (telerik TreeView) 및 RadTreeNode를 교체하고 문제가있는 Tag 속성이 아닙니다 그래서 코드가 잘 실행 편집 * .

+1

'NotifyCollection'의 [documentation] (http://docs.telerik.com/devtools/winforms/api/html/t_telerik_collections_generic_notifycollection_1.htm)은 자체 RemoveAt를 노출하지 않는다는 것을 보여줍니다. 그러나 인덱스 기반의'RemoveItem' 메소드를 노출합니다. 'NotifyCollection .RemoveItem'을 호출하여 콜렉션을'Collection .RemoveAt'로 바꾸면 어떻게됩니까? Telerik에 대한 불쾌감은 없지만 일관되게 구현되지 않은 것일 수 있습니다. – dlatikay

+0

'RemoveItem()'객체에는 deos가 존재하지 않습니다. 가장 좋은 내가'제거 (노드)'및'제거 (문자열 개체 이름)'하고 둘 다 작동하지 않습니다. – Franck

+0

@Franck RadTreeNodeCollection을 사용하고 있습니까? [문서] (http://docs.telerik.com/devtools/winforms/api/html/m_telerik_wincontrols_ui_radtreenodecollection_removeitem.htm)에 따르면 하나가 있습니다. –

답변

0

RadTreeviewTreeView으로 변경하여 문제를 해결했으며 모두 RadTreeNode에서 TreeNode으로 변경했으며 모두 똑같은 코드로 올바르게 작동합니다.