Reader Level:
ARTICLE

Knob Control using Windows Forms and GDI+

On May 13, 2002 Articles | GDI+ & Graphics
Control creation for windows form was never so easy like its now with .Net, although it needs some math skills if you want to create self drawn control.
  • 0
  • 0
  • 37968
Download Files:
 

Control creation for windows form was never so easy like its now with .Net, although it needs some math skills if you want to create self drawn control. I havent seen much of examples to create such controls so I decided to make one. 

You must be familiar with slider control for windows form, my example Knob control is very much similar to that control in respect of functionality but there is major change in GUI. 

  • I have inherited control from UserControl class to make application simpler.
  • Delegates used for event handling of value changed.
  • Read carefully what is done in overriding IsInputKey method because by default using up down keys will change focus from object.
  • I have created variable _IsFocused that will show if object is in focus.
  • For sample I have selected Label control whose color will change when you will change value of three knob controls.

KnobControl.cs is Code for control.

Utility.cs contains important static methods used for Drawing.

Form1.cs is sample that shows use of knob Control. 

However lots of checking will be required to use this control in commercial application but this sample will give you head start if you are going in that direction.

Jigar Desai

Jigar Desai is a Microsoft certified professional and has 8 years of experience in Microsoft technologies, he is working in asp.net since pre beta releases and has extensive experience in developing ...

Personal Blog: http://www.jigar.net
  • 223rank
  • 1M readers
COMMENT USING

Trending up