GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 : TrackBarCell クラス |
Public Class TrackBarCell Inherits Cell Implements IEditingCell
public class TrackBarCell : Cell, IEditingCell
TrackBarCellクラスは、トラックバーコントロールを表示する特別なタイプのCellです。TrackBarCellはIEditingCellインタフェースを実装しているので、編集コントロールなしで編集できます。現在のセルがTrackBarCellで、編集状態にある場合、ユーザーはマウスでつまみをドラッグするか、キーボードの[↑]、[↓]、[←]、[→]、[Home]、[End]、[PageUp]、[PageDown]の各キーを押すことによって、セルの値を編集できます。
TrackBarCellはスクロールバーコントロールに似ています。TrackBarCellのCell.Valueプロパティの値の範囲は、Minimumプロパティ(範囲の下限)とMaximumプロパティ(範囲の上限)によって指定します。
継承時の注意:
TrackBarCellから継承した派生クラスに新しいプロパティを追加するときは、必ずCloneメソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスのCloneメソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。
using System; using System.Windows.Forms; using System.Drawing; namespace GrapeCity.Win.MultiRow.SampleCode { public class TrackBarCellDemo : Form { private GcMultiRow gcMultiRow1 = new GcMultiRow(); private Label label = new Label(); public TrackBarCellDemo() { this.Text = "TrackBarCell Demo"; this.gcMultiRow1.Dock = DockStyle.Fill; this.Controls.Add(this.gcMultiRow1); this.Load += new EventHandler(Form1_Load); this.gcMultiRow1.CellEditedFormattedValueChanged += new EventHandler<CellEditedFormattedValueChangedEventArgs>(gcMultiRow1_CellEditedFormattedValueChanged); this.label.Dock = DockStyle.Bottom; this.label.Height = 30; this.label.BackColor = SystemColors.Info; this.label.Text = "Select one Cell, Drag the track bar or press the Up or Down key to move the slider"; this.Controls.Add(label); this.Size = new Size(400, 600); } void gcMultiRow1_CellEditedFormattedValueChanged(object sender, CellEditedFormattedValueChangedEventArgs e) { if (this.gcMultiRow1.IsCurrentCellInEditMode) { label.Text = (this.gcMultiRow1.CurrentCell as IEditingCell).EditingCellFormattedValue.ToString(); } } private void Form1_Load(object sender, EventArgs e) { TrackBarCell trackBarCell1 = new TrackBarCell(); trackBarCell1.Size = new Size(80, 80); //When the slider is dragged to the top, the Cell.FormattedValue will be 20. trackBarCell1.Maximum = 20; //When the slider is dragged to the bottom, the Cell.FormattedValue will be 10. trackBarCell1.Minimum = 10; //Press the Up or Down key, 2 positions will be moved. trackBarCell1.SmallChange = 2; //Click on the track bar, 5 positions will be moved. trackBarCell1.LargeChange = 5; //Between each tick mark, there exists 2 positions. trackBarCell1.TickFrequency = 2; TrackBarCell trackBarCell2 = trackBarCell1.Clone() as TrackBarCell; //Track bar will be lay out at vertical orientation. trackBarCell2.Orientation = Orientation.Vertical; trackBarCell2.TickStyle = TickStyle.Both; Template template1 = Template.CreateGridTemplate(new Cell[] { trackBarCell1, trackBarCell2 }); gcMultiRow1.Template = template1; gcMultiRow1.RowCount = 3; } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new TrackBarCellDemo()); } } }
Imports System Imports System.Windows.Forms Imports System.Drawing Imports GrapeCity.Win.MultiRow Public Class TrackBarCellDemo Inherits Form Friend WithEvents gcMultiRow1 As New GcMultiRow() Private label As New Label() Public Sub New() Me.Text = "TrackBarCell Demo" Me.gcMultiRow1.Dock = DockStyle.Fill Me.Controls.Add(Me.gcMultiRow1) Me.label.Dock = DockStyle.Bottom Me.label.Height = 30 Me.label.BackColor = SystemColors.Info Me.label.Text = "Select one Cell, Drag the track bar or press the Up or Down key to move the slider" Me.Controls.Add(label) Me.Size = New Size(400, 600) End Sub Private Sub gcMultiRow1_CellEditedFormattedValueChanged(ByVal sender As Object, ByVal e As CellEditedFormattedValueChangedEventArgs) Handles gcMultiRow1.CellEditedFormattedValueChanged If Me.gcMultiRow1.IsCurrentCellInEditMode Then label.Text = TryCast(Me.gcMultiRow1.CurrentCell, IEditingCell).EditingCellFormattedValue.ToString() End If End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim trackBarCell1 As New TrackBarCell() trackBarCell1.Size = New Size(80, 80) 'When the slider is dragged to the top, the Cell.FormattedValue will be 20. trackBarCell1.Maximum = 20 'When the slider is dragged to the bottom, the Cell.FormattedValue will be 10. trackBarCell1.Minimum = 10 'Press the Up or Down key, 2 positions will be moved. trackBarCell1.SmallChange = 2 'Click on the track bar, 5 positions will be moved. trackBarCell1.LargeChange = 5 'Between each tick mark, there exists 2 positions. trackBarCell1.TickFrequency = 2 Dim trackBarCell2 = TryCast(trackBarCell1.Clone(), TrackBarCell) 'Track bar will be lay out at vertical orientation. trackBarCell2.Orientation = Orientation.Vertical trackBarCell2.TickStyle = TickStyle.Both Dim template1 As Template = Template.CreateGridTemplate(New Cell() {trackBarCell1, trackBarCell2}) gcMultiRow1.Template = template1 gcMultiRow1.RowCount = 3 End Sub <STAThreadAttribute()> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New TrackBarCellDemo()) End Sub End Class
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
GrapeCity.Win.MultiRow.Cell
GrapeCity.Win.MultiRow.TrackBarCell