Exemple #1
0
        /// <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(LinkableTreeView 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);
                }
            }
        }
Exemple #2
0
 /// <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(LinkableTreeView source, LinkableTreeView 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);
 }