本文整理汇总了C#中System.Windows.Forms.TrackBar.TickFrequency属性的典型用法代码示例。如果您正苦于以下问题:C# TrackBar.TickFrequency属性的具体用法?C# TrackBar.TickFrequency怎么用?C# TrackBar.TickFrequency使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Windows.Forms.TrackBar
的用法示例。
在下文中一共展示了TrackBar.TickFrequency属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TrackBar trackBar1;
private System.Windows.Forms.TextBox textBox1;
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
public Form1()
{
this.textBox1 = new System.Windows.Forms.TextBox();
this.trackBar1 = new System.Windows.Forms.TrackBar();
// TextBox for TrackBar.Value update.
this.textBox1.Location = new System.Drawing.Point(240, 16);
this.textBox1.Size = new System.Drawing.Size(48, 20);
// Set up how the form should be displayed and add the controls to the form.
this.ClientSize = new System.Drawing.Size(296, 62);
this.Controls.AddRange(new System.Windows.Forms.Control[] {this.textBox1,this.trackBar1});
this.Text = "TrackBar Example";
// Set up the TrackBar.
this.trackBar1.Location = new System.Drawing.Point(8, 8);
this.trackBar1.Size = new System.Drawing.Size(224, 45);
this.trackBar1.Scroll += new System.EventHandler(this.trackBar1_Scroll);
// The Maximum property sets the value of the track bar when
// the slider is all the way to the right.
trackBar1.Maximum = 30;
// The TickFrequency property establishes how many positions
// are between each tick-mark.
trackBar1.TickFrequency = 5;
// The LargeChange property sets how many positions to move
// if the bar is clicked on either side of the slider.
trackBar1.LargeChange = 3;
// The SmallChange property sets how many positions to move
// if the keyboard arrows are used to move the slider.
trackBar1.SmallChange = 2;
}
private void trackBar1_Scroll(object sender, System.EventArgs e)
{
// Display the trackbar value in the text box.
textBox1.Text = "" + trackBar1.Value;
}
}
示例2: TrackBars
//引入命名空间
using System;
using System.Drawing;
using System.Windows.Forms;
public class TrackBars : Form
{
Panel pnl;
PictureBox pb;
TrackBar htbar;
TrackBar vtbar;
public TrackBars()
{
Size = new Size(500,520);
Image img = Image.FromFile("YourFile.bmp");
pnl = new Panel();
pnl.Parent = this;
pnl.BorderStyle = BorderStyle.FixedSingle;
pnl.Size = new Size(400,400);
pnl.Location = new Point(10,10);
pb = new PictureBox();
pb.Parent = pnl;
pb.Size = new Size(200, 200);
pb.Location = new Point((pnl.Size.Width / 2) - (pb.Size.Width / 2),
(pnl.Size.Height / 2) - (pb.Size.Height /2));
pb.BorderStyle = BorderStyle.FixedSingle;
pb.SizeMode = PictureBoxSizeMode.StretchImage;
pb.Image = img;
htbar = new TrackBar();
htbar.Parent = this;
htbar.Orientation = Orientation.Horizontal;
htbar.Size = new Size(pnl.Width, 10);
htbar.Location = new Point(pnl.Left, pnl.Bottom + 25);
htbar.TickStyle = TickStyle.BottomRight;
htbar.TickFrequency = 25;
htbar.Minimum = 25;
htbar.Maximum = 400;
htbar.SmallChange = 10;
htbar.LargeChange = 25;
htbar.BackColor = Color.Yellow;
htbar.Value = pb.Width;
htbar.ValueChanged += new EventHandler(htbar_OnValueChanged);
vtbar = new TrackBar();
vtbar.Parent = this;
vtbar.Orientation = Orientation.Vertical;
vtbar.Size = new Size(25, pnl.Height);
vtbar.Location = new Point(pnl.Right + 25, pnl.Top);
vtbar.TickStyle = TickStyle.Both;
vtbar.SetRange(25,400);
vtbar.SmallChange = 10;
vtbar.LargeChange = 50;
vtbar.TickFrequency = vtbar.Maximum / 20;
vtbar.BackColor = Color.Pink;
vtbar.Value = pb.Height;
vtbar.ValueChanged += new EventHandler(vtbar_OnValueChanged);
}
private void htbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(htbar.Value, pb.Height);
}
private void vtbar_OnValueChanged(object sender, EventArgs e)
{
pb.Size = new Size(pb.Width, vtbar.Value);
}
static void Main()
{
Application.Run(new TrackBars());
}
}