/// <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(LinkedTreeView 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); } } } }
public void RemoveLinkedTreeView(LinkedTreeView treeView) { if (this.linkedTreeViews.Contains(treeView)) this.linkedTreeViews.Remove(treeView); if (treeView.linkedTreeViews.Contains(this)) treeView.linkedTreeViews.Remove(this); }
/// <summary> /// Sets the destination's scroll positions to that of the source. /// </summary> /// <param name="source">The source of the scroll positions.</param> /// <param name="dest">The destinations to set the scroll positions for.</param> private void SetScrollPositions(LinkedTreeView source, LinkedTreeView dest) { //get the scroll positions of the source int horizontal = User32.GetScrollPos(source.Handle, Orientation.Horizontal); int vertical = User32.GetScrollPos(source.Handle, Orientation.Vertical); //set the scroll positions of the destination User32.SetScrollPos(dest.Handle, Orientation.Horizontal, horizontal, true); User32.SetScrollPos(dest.Handle, Orientation.Vertical, vertical, true); }
public void RemoveLinkedTreeView(LinkedTreeView treeView) { if (this.linkedTreeViews.Contains(treeView)) { this.linkedTreeViews.Remove(treeView); } if (treeView.linkedTreeViews.Contains(this)) { treeView.linkedTreeViews.Remove(this); } }
/// <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(LinkedTreeView 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); } } }