[Mono-bugs] [Bug 76826][Wis] New - After Select Events in TreeView not triggered

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Nov 25 20:04:19 EST 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by aviary.tree at ntlworld.com.

http://bugzilla.ximian.com/show_bug.cgi?id=76826

--- shadow/76826	2005-11-25 20:04:19.000000000 -0500
+++ shadow/76826.tmp.11244	2005-11-25 20:04:19.000000000 -0500
@@ -0,0 +1,343 @@
+Bug#: 76826
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: SUSE 10.0
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: Windows.Forms
+AssignedTo: peter at novonyx.com                            
+ReportedBy: aviary.tree at ntlworld.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: After Select Events in TreeView not triggered
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+For a program with a TreeView, with an event handler set up for AfterSelect
+events, if you click on a node, nothing happens.
+
+Steps to reproduce the problem:
+1. Compile and run the program below.  You will need to change the
+directory to one that exists and is accessible on your installation, and
+also find three icon files..
+2. Click on any node - nothing happens.  A message box should have appeared.
+3. Click on a "+" expanding a node. A message box appears with the name of
+the clicked node.  This shows that the BeforeExpand event trigger does work.
+
+Actual Results:
+Clicking on a node: the AfterSelect event handler was not triggered, as
+shown by the absence of a message box pop-up.
+
+Expected Results:
+Clicking on a node: the AfterSelect event handler should have been
+triggered, which would have produced a message box pop-up.
+
+
+How often does this happen? 
+Every time for this event type. Other event types such as BeforeExpand do
+have their event handler triggered.  I can't say I've checked them all, but
+AfterSelect is important to me and I think generally.
+
+Additional Information:
+
+Demonstration code:
+
+using System;
+
+using System.Drawing;
+
+using System.Windows.Forms;
+
+using System.IO;
+
+
+
+namespace treeview1
+
+{
+
+	public class Form1 : System.Windows.Forms.Form
+
+	{	 
+
+	  private System.Windows.Forms.Button button1;
+
+	  private System.Windows.Forms.ImageList imageList1;
+
+	  private System.Windows.Forms.TreeView treeView1;
+
+	  private string BaseDir;
+
+
+
+	  public Form1()
+
+	  {
+
+			InitializeComponent();				
+
+ 			Icon icon1 = new Icon("drive.ico");  // icon file
+
+ 			imageList1.Images.Add(icon1);
+
+ 			Icon icon2 = new Icon("icon2.ico");  // icon file
+
+ 			imageList1.Images.Add(icon2);
+
+ 			Icon icon3 = new Icon("icon3.ico");  // icon file
+
+ 			imageList1.Images.Add(icon3); 		
+
+
+
+			BaseDir = "/home/barry";	 //  CHANGE
+
+			TreeNode tn = Set_Root(BaseDir);	
+
+			Show_Subdirs(tn, BaseDir, true, 2);	
+
+			tn.Expand();
+
+	  }
+
+	  private void InitializeComponent() {
+
+		 	
+
+			this.treeView1 = new System.Windows.Forms.TreeView();				
+
+			this.imageList1 = new System.Windows.Forms.ImageList () ;	
+
+			this.button1 = new System.Windows.Forms.Button();		
+
+			this.SuspendLayout();
+
+			// 
+
+			// Form1
+
+			// 
+
+			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
+
+			this.ClientSize = new System.Drawing.Size(290, 405);
+
+			this.MaximizeBox = false;
+
+			this.Name = "Form1";
+
+			this.Text = "Directories";
+
+			// 
+
+			// treeView1
+
+			// 
+
+			this.treeView1.ImageList = this.imageList1;
+
+			this.treeView1.Location = new System.Drawing.Point(5, 5);
+
+			this.treeView1.Name = "treeView1";
+
+			this.treeView1.Size = new System.Drawing.Size(280, 368);
+
+			this.treeView1.TabIndex = 0;		
+
+			this.treeView1.ImageList = imageList1;
+
+			this.treeView1.ShowRootLines = true;
+
+			this.treeView1.ShowLines = true;
+
+			this.treeView1.ShowPlusMinus = true;
+
+			this.treeView1.AfterSelect += new
+System.Windows.Forms.TreeViewEventHandler(this.TreeView1AfterSelect);
+
+			this.treeView1.BeforeExpand += new
+System.Windows.Forms.TreeViewCancelEventHandler(this.TreeView1BeforeExpand);
+	       
+
+			// 
+
+			// button1
+
+			// 
+
+			this.button1.Location = new System.Drawing.Point(110, 380);
+
+			this.button1.Name = "button1";
+
+			this.button1.Size = new System.Drawing.Size(60, 20);
+
+			this.button1.TabIndex = 1;
+
+			this.button1.Text = "Dismiss";
+
+			this.button1.Click += new System.EventHandler(this.button1_Click);
+
+			// 
+
+			// imageList1
+
+			// 
+
+			this.imageList1.ImageSize = new System.Drawing.Size(16, 16);			
+
+			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
+
+			//		
+
+			this.Controls.Add(this.button1);		
+
+			this.Controls.Add(this.treeView1);		
+
+			this.ResumeLayout(false);
+
+		}
+
+
+
+		[STAThread]
+
+		static void Main() 
+
+		{
+
+			Application.Run(new Form1());
+
+		}
+
+
+
+		private void button1_Click(object sender, System.EventArgs e)
+
+		{
+
+			Application.Exit();
+
+		}
+
+
+
+		private TreeNode Set_Root(string rootdir)
+
+		{
+
+		TreeNode tn = new TreeNode(rootdir, 1, 0);			
+
+			treeView1.Nodes.Add(tn);
+
+			return tn;
+
+		}
+
+		
+
+		private void Show_Subdirs(TreeNode tn, string startdir, bool recurse, int
+levels)
+
+		{
+
+		  int i = 0;		  
+
+		  DirectoryInfo di = new DirectoryInfo(startdir);
+
+		  try {
+
+		  // Get a reference to each directory in that directory.
+
+		  DirectoryInfo[] diArr = di.GetDirectories();			
+
+		  if (tn.Nodes.Count == 0) {  // no child nodes
+
+				foreach (DirectoryInfo dri in diArr) {
+
+					TreeNode tnx = new TreeNode(dri.Name, 1, 2);
+
+					tn.Nodes.Add(tnx);
+
+					i++;
+
+					string fullpath = startdir + "/" + dri.Name;				
+
+					if ((recurse == true) && (levels > 0)) {
+
+						Show_Subdirs(tnx, fullpath, true, levels-1);
+
+					}
+
+				}
+
+		  }
+
+		  else {  // child nodes exist so don't duplicate them
+
+				if (recurse == true) {
+
+					TreeNode child = tn.FirstNode;					
+
+					while (child != null) {
+
+						string extpath = startdir + "/" + child.Text;
+
+						Show_Subdirs(child, extpath, false, levels-1);	
+
+						child = child.NextNode;
+
+					}
+
+				}
+
+		  }
+
+		  } catch {  // errors where directory does not have access permission
+
+			
+
+		   }		  
+
+		}		
+
+		
+
+	        void TreeView1AfterSelect(object sender,
+System.Windows.Forms.TreeViewEventArgs e)
+
+		{		 
+
+		    MessageBox.Show("After Select Event happened on node  "+e.Node.Text,
+"Event handler");
+
+		    // string path =  e.Node.FullPath;
+
+
+
+		}
+
+		void TreeView1BeforeExpand(object sender,
+System.Windows.Forms.TreeViewCancelEventArgs e)
+
+		{
+
+		    if (e.Node.Text != BaseDir) {
+
+		       MessageBox.Show("Before Expand Event happened on node 
+"+e.Node.Text, "Event handler");
+
+		    }
+
+		}
+
+				
+
+	}
+
+}


More information about the mono-bugs mailing list