PowerTools PlusPak for Windows Forms 8.0J
TickFrequency プロパティ
使用例 

コントロールに描画された目盛り間のデルタを示す値を取得または設定します。
構文
Public Property TickFrequency As Integer
public int TickFrequency {get; set;}

プロパティ値

目盛り間のデルタを表す数値。デフォルト値は 1 です。
解説
Minimum プロパティから Maximum プロパティまでの値の範囲が大きい GcTrackBar の場合、コントロールの値に対応する目盛りをすべて描画するのは実際的ではありません。たとえば、コントロールの値の範囲が 100 の場合にこのプロパティの値を 5 に設定すると、20 個の目盛りがコントロールに描画されます。この場合、各目盛りは値の範囲内の 5 単位を表します。
使用例

次のサンプルコードは、GcTrackBar コントロールを含むフォームを表示し、TickFrequency、MinimumMaximumTickStyleDragFrequencyLargeChangeSmallChange の各プロパティの設定例と Scroll イベントの処理例を示します。このサンプルを実行するには、TextBox1 という名前の System.Windows.Forms.TextBox コントロールを含むフォームに以下のコードを貼り付けて、フォームのコンストラクターまたは System.Windows.Forms.Form.Load イベント処理メソッドから CreateGcTrackBarWithNormalStyle メソッドを呼び出します。

private void CreateGcTrackBarWithNormalStyle()
{
    // Create a instance of GcTrackBar.
    GrapeCity.Win.Bars.GcTrackBar gcTrackBar1 = new GrapeCity.Win.Bars.GcTrackBar();

    // Initialize the Name, Location and Size of GcTrackBar
    gcTrackBar1.Name = "gcTrackBar1";
    gcTrackBar1.Location = new System.Drawing.Point(8, 8);
    gcTrackBar1.Size = new System.Drawing.Size(224, 45);
    gcTrackBar1.Scroll += new EventHandler(gcTrackBar1_Scroll);

    // Add the second Thumb to the Thumbs of GcTrackBar
    GrapeCity.Win.Bars.Thumb thumb1 = new GrapeCity.Win.Bars.Thumb();
    gcTrackBar1.Thumbs.Add(thumb1);

    // Set the upper limit of thumb value. 
    gcTrackBar1.Maximum = 30;

    // Set the lower limit of thumb value.
    gcTrackBar1.Minimum = 5;

    // Set the distance value between each tick-mark.
    gcTrackBar1.TickFrequency = 5;

    // Show both tick-marks on the BottomRight and TopLeft.
    gcTrackBar1.TickStyle = TickStyle.Both;

    // Set the delta value of thumb moving by mouse dragging
    gcTrackBar1.DragFrequency = 2;

    // The LargeChange property sets how many positions to move
    // if the bar is clicked on either side of the slider.
    gcTrackBar1.LargeChange = 3;

    // The SmallChange property sets how many positions to move
    // if the keyboard arrows are used to move the slider.
    gcTrackBar1.SmallChange = 2;

    // Add gcTrackBar1 to the form
    this.Controls.Add(gcTrackBar1);
}

void gcTrackBar1_Scroll(object sender, EventArgs e)
{
    // Display the vlaue of current selected Thumb in the text box.
    GcTrackBar trackbar = (GcTrackBar)sender;
    GrapeCity.Win.Bars.Thumb selectedThumb = trackbar.Thumbs[trackbar.SelectedThumbIndex];
    this.textBox1.Text = "" + selectedThumb.Value;
}
Private Sub CreateGcTrackBarWithNormalStyle()
    ' Create a instance of GcTrackBar.
    Dim gcTrackBar1 As New GcTrackBar()

    ' Initialize the Name, Location and Size of GcTrackBar
    gcTrackBar1.Name = "gcTrackBar1"
    gcTrackBar1.Location = New System.Drawing.Point(8, 8)
    gcTrackBar1.Size = New System.Drawing.Size(224, 45)

    AddHandler gcTrackBar1.Scroll, AddressOf gcTrackBar1_Scroll

    ' Add the second Thumb to the Thumbs of GcTrackBar
    Dim thumb1 As New Thumb()
    gcTrackBar1.Thumbs.Add(thumb1)

    ' Set the upper limit of thumb value. 
    gcTrackBar1.Maximum = 30

    ' Set the lower limit of thumb value.
    gcTrackBar1.Minimum = 5

    ' Set the distance value between each tick-mark.
    gcTrackBar1.TickFrequency = 5

    ' Show both tick-marks on the BottomRight and TopLeft.
    gcTrackBar1.TickStyle = TickStyle.Both

    ' Set the delta value of thumb moving by mouse dragging
    gcTrackBar1.DragFrequency = 2

    ' The LargeChange property sets how many positions to move
    ' if the bar is clicked on either side of the slider.
    gcTrackBar1.LargeChange = 3

    ' The SmallChange property sets how many positions to move
    ' if the keyboard arrows are used to move the slider.
    gcTrackBar1.SmallChange = 2

    ' Add gcTrackBar1 to the form
    Me.Controls.Add(gcTrackBar1)
End Sub

Private Sub gcTrackBar1_Scroll(ByVal sender As Object, ByVal e As EventArgs)
    ' Display the vlaue of current selected Thumb in the text box.
    Dim trackbar As GcTrackBar = DirectCast(sender, GcTrackBar)
    Dim selectedThumb As Thumb = trackbar.Thumbs(trackbar.SelectedThumbIndex)
    Me.textBox1.Text = "" + selectedThumb.Value.ToString()
End Sub
プラットフォーム

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

参照

GcTrackBar クラス
GcTrackBar メンバ

Send Feedback