Click here to Skip to main content
15,896,606 members
Articles / Programming Languages / C#

DropDownPanel

Rate me:
Please Sign up or sign in to vote.
4.87/5 (26 votes)
11 Feb 2007Public Domain4 min read 121.1K   2K   107  
A template for custom ComboBoxes
using System;
using System.Drawing;
using System.Windows.Forms;

namespace AT.STO.UI.Win
{
	/// <summary>
	/// Represents the method which responds to a <see cref="DropDownCancel"/> event.
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	public delegate void DropDownCancelEventHandler(object sender, DropDownCancelEventArgs e);
	
	/// <summary>
	/// Represents the method which responds to a <see cref="DropDownClosed"/> event.
	/// </summary>
	/// <param name="sender"></param>
	/// <param name="e"></param>
	public delegate void DropDownClosedEventHandler(object sender, DropDownClosedEventArgs e);
	
	/// <summary>
	/// 
	/// </summary>
	/// <param name="sender">The object firing the event.</param>
	/// <param name="e"></param>
	public delegate void DropDownValueChangedEventHandler(object sender, DropDownValueChangedEventArgs e);
	
	/// <summary>
	/// Arguments to a <see cref="DropDownCancelEvent"/>.  Provides a
	/// reference to the popup form that is to be closed and 
	/// allows the operation to be cancelled.
	/// 
	/// Thousand thanks to Steve McMahon:
	/// http://www.vbaccelerator.com/home/NET/Code/Controls/Popup_Windows/Popup_Windows/Popup_Form_Demonstration.asp
	/// </summary>
	public class DropDownCancelEventArgs : EventArgs
	{
	#region Private Variable Declarations
		private bool	_cancel				= false;
		private Point	_cursorLocation;
		private Form	_dropDown			= null;
	#endregion
	#region Constructor / Destructor
		/// <summary>
		/// Constructs a new instance of this class.
		/// </summary>
		/// <param name="DropDown">The popup form</param>
		/// <param name="CursorLocation">The mouse location, if any, where the
		/// mouse event that would cancel the popup occured.</param>
		public DropDownCancelEventArgs(Form DropDown, Point CursorLocation)
		{
			_dropDown		= DropDown;
			_cursorLocation = CursorLocation;
			_cancel			= false;
		}
	#endregion
	#region Public Properties	
		/// <summary>
		/// 
		/// </summary>
		public bool Cancel
		{
			get { return _cancel; }
			set { _cancel = value; }
		}

		/// <summary>
		/// 
		/// </summary>
		public Point CursorLocation
		{
			get { return _cursorLocation; }
		}

		/// <summary>
		/// 
		/// </summary>
		public Form DropDown
		{
			get { return _dropDown; }
		}
	#endregion
	}

	/// <summary>
	/// Contains event information for a <see cref="DropDownClosed"/> event.
	/// 
	/// Thousand thanks to Steve McMahon:
	/// http://www.vbaccelerator.com/home/NET/Code/Controls/Popup_Windows/Popup_Windows/Popup_Form_Demonstration.asp
	/// </summary>
	public class DropDownClosedEventArgs : EventArgs
	{
	#region Private Variable Declarations
		private Form _dropDown = null;
	#endregion
	#region Constructor / Destructor
		/// <summary>
		/// Constructs a new instance of this class for the specified
		/// popup form.
		/// </summary>
		/// <param name="DropDown">DropDown Form which is being closed.</param>
		public DropDownClosedEventArgs(Form DropDown)
		{
			_dropDown = DropDown;
		}
	#endregion
	#region Public Properties
		/// <summary>
		/// Gets the dropdown form which is being closed.
		/// </summary>
		public Form DropDown
		{
			get { return _dropDown; }
		}
	#endregion
	}
	
	/// <summary>
	/// Contains event information for DropDownValueChangedEventHandler.
	/// </summary>
	public class DropDownValueChangedEventArgs : EventArgs
	{
	#region Private Variable Declarations
		private object _value = null;
	#endregion
	#region Constructor / Destructor
		/// <summary>
		/// Default Constructor
		/// </summary>
		public DropDownValueChangedEventArgs()
		{
		}
		
		/// <summary>
		/// Initialization with the control's value.
		/// </summary>
		/// <param name="Value"></param>
		public DropDownValueChangedEventArgs(object Value)
		{
			_value = Value;
		}
	#endregion
	#region Public Properties
		/// <summary>
		/// Gets or sets the control's value.
		/// </summary>
		public object Value
		{
			get { return _value; }
			set { _value = value; }
		}
	#endregion
	}
}

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 A Public Domain dedication


Written By
Technical Lead Artaker Computersysteme GmbH
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions