Knob Control using Windows Forms and GDI+
.net, c#, Control, Delegates, drawing, GDI+, GDI+ and Graphics, graphics, knob Control, object., slider control, userControl class, windows Forms,
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.
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.