Click here to Skip to main content
15,894,410 members
Articles / Programming Languages / Visual Basic

ControlInspector - monitor Windows Forms events as they are fired (like Spy++ for .net)

Rate me:
Please Sign up or sign in to vote.
4.96/5 (86 votes)
30 Apr 2003CPOL6 min read 273.8K   8.3K   176  
ControlInspector hooks on to all events on a given control, user-control or form and shows when they are fired, along with any eventargs. It even handles custom events and custom event args using dynamically generated assemblies.
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace ControlInspector
{
	/// <summary>
	/// Summary description for EventTrackInfo.
	/// </summary>
	public class EventTrackInfo : System.Windows.Forms.UserControl
	{
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public EventTrackInfo()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			// TODO: Add any initialization after the InitForm call

		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.treeView1 = new ControlInspector.HighlightTrackTreeView();
			this.SuspendLayout();
			// 
			// treeView1
			// 
			this.treeView1.CausesValidation = false;
			this.treeView1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.treeView1.ImageIndex = -1;
			this.treeView1.Name = "treeView1";
			this.treeView1.SelectedImageIndex = -1;
			this.treeView1.Size = new System.Drawing.Size(600, 400);
			this.treeView1.TabIndex = 0;
			// 
			// EventTrackInfo
			// 
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.treeView1});
			this.Name = "EventTrackInfo";
			this.Size = new System.Drawing.Size(600, 400);
			this.ResumeLayout(false);

		}
		#endregion

		[Browsable(false)]
		public TreeView TreeView {
			get {
				return treeView1;
			}
		}

		object selectedObject;
		private ControlInspector.HighlightTrackTreeView treeView1;
	
		[Browsable(false)]
		public object SelectedObject {
			set {
				selectedObject = value;
			}
			get {
				return selectedObject;
			}
		}

		ArrayList eventList;
		public ArrayList EventList {
			set {
				eventList = value;
			}
			get {
				return eventList;
			}
		}

		public override ContextMenu ContextMenu {
			set {
				treeView1.ContextMenu = value;
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
Director of Adastra Software Ltd, a UK based provider of point of care information systems.

Comments and Discussions