Parcourir la source

* TreeView.cs: Don't try to find the clicked on node if there are
no nodes in the tree.


svn path=/trunk/mcs/; revision=51474

Jackson Harper il y a 20 ans
Parent
commit
9ca068c2bb

+ 5 - 0
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,8 @@
+2005-10-08  Jackson Harper  <[email protected]>
+
+	* TreeView.cs: Don't try to find the clicked on node if there are
+	no nodes in the tree.
+
 2005-10-08  Alexander Olk  <[email protected]>
 
 	* RichTextBox.cs:

+ 4 - 17
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs

@@ -756,7 +756,10 @@ namespace System.Windows.Forms {
 		}
 
 		[MonoTODO ("Need to know if we are editing, not if editing is enabled")]
-		private TreeNode GetNodeAt (int y) {
+		private TreeNode GetNodeAt (int y)
+		{
+			if (nodes.Count <= 0)
+				return null;
 
 			if (top_node == null)
 				top_node = nodes [0];
@@ -1260,22 +1263,6 @@ namespace System.Windows.Forms {
 			XplatUI.ScrollWindow (Handle, ViewportRectangle, old_offset - hbar_offset, 0, false);
 		}
 
-		private int GetOpenNodeCount ()
-		{
-
-			if (Nodes.Count < 1)
-				return 0;
-
-			OpenTreeNodeEnumerator e = new OpenTreeNodeEnumerator (root_node.Nodes [0]);
-
-			int count = 0;
-			while (e.MoveNext ()) {
-				count++;
-			}
-
-			return count;
-		}
-
 		private void MouseDownHandler (object sender, MouseEventArgs e)
 		{
 			TreeNode node = GetNodeAt (e.Y);