$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
WinForms Track and Status Control
Easily customizing Track and Status controls and build interactive and attractive UI
Home > WinForms UI Controls > User Manual > Customize Track Bar in C#

Customization of TrackBar control in C#.NET

KetticTrackBar control for WinForms is used to customize the slider and assign a value on a bar by moving a slider. It provides a horizontal bar and a vertical bar with a sliding handle that can be moved by using the mouse and a series of marks. The users of your Windows Forms application can set the slider in horizontal and vertical direction as well as at an arbitrary angle. The following C# tutorial demonstrates how to customize the track bar by using its properties.

Properties for Customizing TrackBar control in Windows Forms

To customize the appearance and behavior of the track bar in your C# Windows Forms application, we can use the properties of KetticTrackBar as below.
  • Value, this property is used to assign the value to the thumb when it is in the mode of KetticTrackBar

this.ketticTrackBar1.Value = 5;
  • Minimum and Maximum, these two properties are used to define the range that the thumbs can scroll over. The following C# code snippet shows how to achieve this.

this.ketticTrackBar1.Minimum = 10;
this.ketticTrackBar1.Maximum = 120;
  • Orientation, this property is used to change the orientation of the KetticTrackBar control. Its valid value includes Horizontal or Vertical. The default setting is Horizontal. The C# code sample below shows how to change the orientation to be Vertical.

this.ketticTrackBar1.Orientation = Orientation.Vertical;
  • TickStyle, this property allows the developers to draw the tick marks on one or both sides of the KetticTrackBar. Its valid value includes None, Both, TopLeft, and BottomRight. None value will disable the ticks; Both value will enable ticks on both sides; TopLeft value will display the ticks on the top side; And the BottomRight value will display the ticks on the down side. The following C# code shows how to set this property to be None, which is the default setting.

this.ketticTrackBar1.TickStyle = Kettic.WinForms.Enumerations.TickStyles.None;
  • TextOrientation, this property is used to display the associated texts in horizontal or vertical direction. The C# code snippet demonstrates how to change the orientation

this.ketticTrackBar1.TextOrientation = Orientation.Vertical;
  • LargeChange, this property is used to set the change in value when clicking outside of the slider makes using the mouse. The C# code below shows how to set the LargeChange property.

this.ketticTrackBar1.LargeChange = 5;
  • ShowButtons, this property is used to display the navigation buttons in KetticTrackBar. The default setting disables this feature. The following C# code snippet shows how to enable this functionality to display navigation buttons.

this.ketticTrackBar1.ShowButtons = true;
  • LabelStyle, this property is used to display the labels. Its valid values include None, Both, TopLeft, and BottomRight. The None value will disable the functionality to display the labels, the Both value will show the labels on both sides, the TopLeft value will display the labels on the top side, and the BottonRight will show the labels on the bottom side. The C# code below demonstrates how to set this property.

this.ketticTrackBar1.LabelStyle = Kettic.WinForms.UI.TrackBarLabelStyle.Both;
  • TrackBarMode, this property is used to set the mode to the TrackBar control. The modes available to KetticTrackBar include SingleThumb, StartFromTheBeggining, and Range, whose functionalities and behaviors varies. The C# code shows how to set the mode to be SingleThumb.

this.ketticTrackBar1.TrackBarMode = Kettic.WinForms.UI.TrackBarRangeMode.SingleThumb;
  • SmallTickFrequency, this property is used to set the space between the small tick marks and the C# code below show how to change the value.

this.ketticTrackBar1.SmallTickFrequency = 2;
  • LargeTickFrequency, this property is used to set the space between the large tick marks and the C# code below show how to achieve this.

this.ketticTrackBar1.LargeTickFrequency = 10;
  • ShowSlideArea, this property is used to display the slider rides line down the middle of the KetticTrackBar control. The C# code below enables this functionality.

this.ketticTrackBar1.ShowSlideArea = true;
  • ThumbSize, this property is able to change the size of the thumbs. The C# code below shows how to do it

this.ketticTrackBar1.ThumbSize = new Size(16, 18);
  • SnapMode, this property determines how the thumb moves in KetticTrackBar control. The C# code snippet below set this property to be SnapToTicks, which moves the thumb at tick positions.

this.ketticTrackBar1.SnapMode = TrackBarSnapModes.SnapToTicks;

Events for Customizing TrackBar control in Windows Forms

KetticTrackBar WinForms control contains a few events for the designers to customize this control.
  • ValueChanged, this event is used to get the value of KetticTrackBar from the Value property. It will be fired when dragging and dropping the thumb on the slider area or setting the Value property.
  • LableFormatting, this event is used to format the labels. The following C# code shows how to format the labels via this event.

void ketticTrackBar1_TickFormatting(object sender, TickFormattingEventArgs e)
{
e.TickElement.Line1.BackColor = Color.Red;
}
  • TickFormatting, this event is used to format the ticks. The following C# code shows how to change the color of the ticks

void ketticTrackBar1_LabelFormatting(object sender, LabelFormattingEventArgs e)
{
e.LabelElement.ForeColor = Color.Yellow;
}
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls