TrackBar



  • Similar to numericupdown, but it offers visualization for the value selection. 
  • Naming Convension: trkXXXX
 
Properties of TrackBar
Property
Description
Value
Gets or sets the current value in the control.
Minimum
Specifies the minimum value in the range.
Maximum
Specifies the maximum value in the range.
TickFrequency
Specifies the difference between each tick.
Orientation
Horizontal / Vertical
TickStyle
None, TopLeft, BottomRight, Both
Name, BackColor, ForeColor, Enabled, Visible, Size, Location, ContextMenuStrip, BorderStyle





Events of TrackBar
Events

Scroll, Click, DoubleClick, MouseMove, MouseEnter, MouseLeave, KeyPress, Enter, Leave

Example with Track Bar:-

Add a new form to the windows forms Application with the name FormTrackBar
Take two Labels ,one TrackBar on the Form   set the following properties to them 

label1:-

Text                      :         Set Font Size

label2:-

Name                    :         lblDispaly
Text                      :         C#.Net

trackBar1:-

Name                    :         trkFontSize
Minimum               :         1
Maximum              :         300
TickFrequency       :         10


Design:-


Generate the Default Event Scroll of the TrackBar trkFontSize  

Go to source i.e.,FormTrackBar.cs write the following code in it

using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WABasics
{
    public partial class FormTrackBar : Form
    {
        public FormTrackBar()
        {
            InitializeComponent();
        }

        private void trkFontSize_Scroll(object sender, EventArgs e)
        {
            int i = trkFontSize.Value;
            lblDispaly.Font = new Font("Chiller",i);
        }
    }
}



Result:-


No comments:

Post a Comment