/// <summary> /// Links the specified tree view to this tree view. Whenever either treeview /// scrolls, the other will scroll too. /// </summary> /// <param name="treeView">The TreeView to link.</param> public void AddLinkedTreeView(MyTreeView treeView) { if (treeView == this) { throw new ArgumentException("Cannot link a TreeView to itself!", "treeView"); } if (!linkedTreeViews.Contains(treeView)) { //add the treeview to our list of linked treeviews linkedTreeViews.Add(treeView); //add this to the treeview's list of linked treeviews treeView.AddLinkedTreeView(this); //make sure the TreeView is linked to all of the other TreeViews that this TreeView is linked to for (int i = 0; i < linkedTreeViews.Count; i++) { //get the linked treeview var linkedTreeView = linkedTreeViews[i]; //link the treeviews together if (linkedTreeView != treeView) { linkedTreeView.AddLinkedTreeView(treeView); } } } }
/// <summary> /// Links the specified tree view to this tree view. Whenever either treeview /// scrolls, the other will scroll too. /// </summary> /// <param name="treeView">The TreeView to link.</param> public void AddLinkedTreeView(MyTreeView treeView) { if (treeView == this) { throw new ArgumentException("Cannot link a TreeView to itself!", "treeView"); } if (!linkedTreeViews.Contains(treeView)) { //add the treeview to our list of linked treeviews linkedTreeViews.Add(treeView); //add this to the treeview's list of linked treeviews treeView.AddLinkedTreeView(this); } }