TrackBar
Um controle deslizante, também conhecido como Slider, é um objeto de interface gráfica (GUI) com o qual o usuário pode definir um valor movendo um indicador, geralmente de uma forma horizontal. Em alguns casos, o usuário também pode clicar em um ponto no controle deslizante para alterar a configuração.
TickStyle
Especifica a localização das marcas de escala em um controle TrackBar.
Exemplo:
Neste exemplo criamos um TrackBar dinamicamente.
C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TBar { public partial class Form1 : Form { // Declara componentes Label titulo; Label valor; TrackBar slider; Button botao; // Declara variaveis String mostraValor = "Valor escolhido é: "; public Form1() { InitializeComponent(); } private void Form1_Shown(object sender, EventArgs e) { // Muda propriedades do formulario Form1.ActiveForm.Text = "TrackBar"; Form1.ActiveForm.Size = new Size(250, 200); // Cria componentes titulo = new Label(); valor = new Label(); slider = new TrackBar(); botao = new Button(); // Adiciona propriedades titulo.Text = "Desenvolvimento Aberto - TrackBar"; valor.Text = mostraValor; botao.Text = "Ok"; slider.Maximum = 50; slider.Minimum = 1; slider.Value = 25; slider.TickStyle = TickStyle.BottomRight; titulo.Size = new Size(300, 20); valor.Size = new Size(300, 20); titulo.Location = new Point(5, 10); valor.Location = new Point(5, 30); slider.Location = new Point(5, 70); botao.Location = new Point(5, 120); // Cria evento para o botão botao.Click += new System.EventHandler(this.botao_Click); // Adiciona eventos no formulario Form1.ActiveForm.Controls.Add(titulo); Form1.ActiveForm.Controls.Add(valor); Form1.ActiveForm.Controls.Add(slider); Form1.ActiveForm.Controls.Add(botao); } private void botao_Click(object sender, EventArgs e) { // Mostra valor do trackbar valor.Text = mostraValor + Convert.ToString(slider.Value); } } }