GrapeCity.Win.Bars 名前空間 > GcTrackBar クラス : DragFrequency プロパティ |
次のサンプルコードは、DragFrequency および DragMode プロパティの使用方法と ThumbValueChanged イベントの処理例を示します。このサンプルを実行するには、TextBox1 という名前の System.Windows.Forms.TextBox コントロールを含むフォームに以下のコードを貼り付けて、フォームのコンストラクターまたは System.Windows.Forms.Form.Load イベント処理メソッドからこのメソッドを呼び出します。
private void CreateGcTrackBarWithExpectedDragBehavior() { // 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.ThumbValueChanged += new EventHandler<ThumbValueChangedEventArgs>(gcTrackBar1_ThumbValueChanged); // Add the second Thumb to the Thumbs of GcTrackBar GrapeCity.Win.Bars.Thumb thumb1 = new GrapeCity.Win.Bars.Thumb(); gcTrackBar1.Thumbs.Add(thumb1); // Set DragMode property to Trunk, two thumbs can't be covered and crossed together. // When one thumb is next to other one,if try to the preceding thumb, the two thumbs will move together. gcTrackBar1.DragMode = DragMode.Trunk; // Set the delta value of thumb moving by mouse dragging gcTrackBar1.DragFrequency = 2; // Add gcTrackBar1 to the form this.Controls.Add(gcTrackBar1); } void gcTrackBar1_ThumbValueChanged(object sender, ThumbValueChangedEventArgs e) { // Display the changed NewValaue of current selected Thumb in the text box. this.textBox1.Text = "" + e.NewValue; }
Private Sub CreateGcTrackBarWithExpectedDragBehavior() ' 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.ThumbValueChanged, AddressOf gcTrackBar1_ThumbValueChanged ' Add the second Thumb to the Thumbs of GcTrackBar Dim thumb1 As New Thumb() gcTrackBar1.Thumbs.Add(thumb1) ' Set DragMode property to Trunk, two thumbs can't be covered and crossed together. ' When one thumb is next to other one,if try to the preceding thumb, the two thumbs will move together. gcTrackBar1.DragMode = DragMode.Trunk ' Set the delta value of thumb moving by mouse dragging gcTrackBar1.DragFrequency = 2 ' Add gcTrackBar1 to the form Me.Controls.Add(gcTrackBar1) End Sub Private Sub gcTrackBar1_ThumbValueChanged(ByVal sender As Object, ByVal e As ThumbValueChangedEventArgs) ' Display the changed NewValaue of current selected Thumb in the text box. Me.textBox1.Text = "" + e.NewValue.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