PowerTools PlusPak for Windows Forms 8.0J
Scroll イベント
使用例 

マウスまたはキーボード操作によってスクロールボックスが移動したときに発生します。
構文
Public Event Scroll As EventHandler
public event EventHandler Scroll
使用例

次のサンプルコードは、GcTrackBar コントロールを含むフォームを表示し、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