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

A variation on the default TrackBar

Rate me:
Please Sign up or sign in to vote.
4.27/5 (9 votes)
17 Aug 20044 min read 111.6K   3.6K   37  
Multi-Color and multi-directional TrackBar.
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

namespace GradientControls
{
	internal class ColorTrackBarDesigner : System.Windows.Forms.Design.ControlDesigner
	{
		public ColorTrackBarDesigner()
		{}

		// clean up some unnecessary properties
		protected override void PostFilterProperties(IDictionary Properties)
		{
			Properties.Remove("AllowDrop");
			Properties.Remove("BackgroundImage");
			Properties.Remove("ContextMenu");
			Properties.Remove("FlatStyle");
			Properties.Remove("Image");
			Properties.Remove("ImageAlign");
			Properties.Remove("ImageIndex");
			Properties.Remove("ImageList");
			Properties.Remove("Text");
			Properties.Remove("TextAlign");
			Properties.Remove("BackColor");
			Properties.Remove("Font");
			Properties.Remove("ForeColor");
			Properties.Remove("Cursor");
		}
		protected override void PostFilterEvents(IDictionary events)
		{
			//actions
			events.Remove("Click");
			events.Remove("DoubleClick");
			//appearence
			events.Remove("Paint");
			//behavior
			events.Remove("ChangeUICues");
            events.Remove("ImeModeChanged");
			events.Remove("QueryAccessibilityHelp");
			events.Remove("StyleChanged");
			events.Remove("SystemColorsChanged");
			//Drag Drop
			events.Remove("DragDrop");
			events.Remove("DragEnter");
			events.Remove("DragLeave");
			events.Remove("DragOver");
			events.Remove("GiveFeedback");
			events.Remove("QueryContinueDrag");
			events.Remove("DragDrop");
			//layout
			events.Remove("Layout");
			events.Remove("Move");
			events.Remove("Resize");
			//PropertyChanged
			events.Remove("BackColorChanged");
			events.Remove("BackgroundImageChanged");
			events.Remove("BindingContextChanged");
			events.Remove("CausesValidationChanged");
			events.Remove("CursorChanged");
			events.Remove("FontChanged");
			events.Remove("ForeColorChanged");
			events.Remove("RightToLeftChanged");
			events.Remove("SizeChanged");
			events.Remove("TextChanged");
			
			base.PostFilterEvents (events);
		}

	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions