GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 : RadioGroupCell クラス |
Public Class RadioGroupCell Inherits Cell Implements IEditingCell
public class RadioGroupCell : Cell, IEditingCell
RadioGroupCellクラスは、ラジオボタンのセットを表示する特別なタイプのCellです。RadioGroupCellはIEditingCellインタフェースを実装しているので、編集コントロールなしで編集できます。現在のセルがRadioGroupCellで、編集状態にある場合、ユーザーは単純にクリックするか、上下左右の矢印キーを押すことによって、セルの値を編集できます。
ユーザーがRadioGroupCellのラジオボタンを選択すると、同じRadioGroupCell内の他のラジオボタンの選択が解除されます。ラジオグループは、その中の選択肢を1つだけしか選択できないことをユーザーに知らせます。
継承時の注意:
RadioGroupCellから継承した派生クラスに新しいプロパティを追加するときは、必ずCloneメソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスのCloneメソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。
using System; using System.Windows.Forms; using System.Drawing; namespace GrapeCity.Win.MultiRow.SampleCode { public class RadioGroupCellDemo : Form { private GcMultiRow gcMultiRow1 = new GcMultiRow(); private Label label = new Label(); public RadioGroupCellDemo() { this.Text = "RadioGroupCell Demo"; this.gcMultiRow1.Dock = DockStyle.Fill; this.label.Height = 30; this.label.Dock = DockStyle.Bottom; this.label.BackColor = SystemColors.Info; this.label.Text = "Click one cell to show the clicked item."; this.Controls.Add(this.gcMultiRow1); this.Controls.Add(this.label); this.Load += new EventHandler(Form1_Load); this.gcMultiRow1.CellEditedFormattedValueChanged += new EventHandler<CellEditedFormattedValueChangedEventArgs>(gcMultiRow1_CellEditedFormattedValueChanged); this.Size = new Size(400, 400); } private void Form1_Load(object sender, EventArgs e) { RadioGroupCell radioGroupCell1 = new RadioGroupCell(); radioGroupCell1.Size = new Size(150, 60); radioGroupCell1.Items.AddRange(new string[] { "1", "2", "3", "4", "5", "6" }); radioGroupCell1.CheckAlign = ContentAlignment.MiddleLeft; //6 radio will be lay out to 3 columns. radioGroupCell1.ColumnCount = 3; //The radio button will range from left to right. radioGroupCell1.FlowDirection = Orientation.Horizontal; //Between every 2 columns, 20 pixels space exists at least. radioGroupCell1.HorizontalSpace = 20; radioGroupCell1.FlatStyle = FlatStyle.Popup; RadioGroupCell radioGroupCell2 = new RadioGroupCell(); radioGroupCell2.Size = new Size(150, 60); radioGroupCell2.Items.AddRange(new string[] { "11111", "22222", "33333", "44444", "55555", "66666" }); radioGroupCell2.CheckAlign = ContentAlignment.MiddleLeft; //6 radio will be lay out to 3 columns. radioGroupCell2.ColumnCount = 3; //The radio button will range from top to bottom. radioGroupCell2.FlowDirection = Orientation.Vertical; //Between every 2 lines, 20 pixels space exists at least. radioGroupCell2.VerticalSpace = 20; // radioGroupCell2.Ellipsis = MultiRowEllipsisMode.EllipsisEnd; radioGroupCell2.EllipsisString = "..."; Template template1 = Template.CreateGridTemplate(new Cell[] { radioGroupCell1, radioGroupCell2 }); gcMultiRow1.Template = template1; gcMultiRow1.RowCount = 3; } private void gcMultiRow1_CellEditedFormattedValueChanged(object sender, CellEditedFormattedValueChangedEventArgs e) { int itemIndex = (int)(this.gcMultiRow1.GetEditedFormattedValue(e.RowIndex, e.CellIndex)); this.label.Text = "The clicked item is " + (this.gcMultiRow1.CurrentCell as RadioGroupCell).Items[itemIndex]; } [STAThreadAttribute()] public static void Main() { Application.EnableVisualStyles(); Application.Run(new RadioGroupCellDemo()); } } }
Imports System Imports System.Windows.Forms Imports System.Drawing Imports GrapeCity.Win.MultiRow Public Class RadioGroupCellDemo Inherits Form Friend WithEvents gcMultiRow1 As New GcMultiRow() Private label As New Label() Public Sub New() Me.Text = "RadioGroupCell Demo" Me.gcMultiRow1.Dock = DockStyle.Fill Me.label.Height = 30 Me.label.Dock = DockStyle.Bottom Me.label.BackColor = SystemColors.Info Me.label.Text = "Click one cell to show the clicked item." Me.Controls.Add(Me.gcMultiRow1) Me.Controls.Add(Me.label) Me.Size = New Size(400, 400) End Sub Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim radioGroupCell1 As New RadioGroupCell() radioGroupCell1.Size = New Size(150, 60) radioGroupCell1.Items.AddRange(New String() {"1", "2", "3", "4", "5", "6"}) radioGroupCell1.CheckAlign = ContentAlignment.MiddleLeft '6 radio will be lay out to 3 columns. radioGroupCell1.ColumnCount = 3 'The radio button will range from left to right. radioGroupCell1.FlowDirection = Orientation.Horizontal 'Between every 2 columns, 20 pixels space exists at least. radioGroupCell1.HorizontalSpace = 20 radioGroupCell1.FlatStyle = FlatStyle.Popup Dim radioGroupCell2 As New RadioGroupCell() radioGroupCell2.Size = New Size(150, 60) radioGroupCell2.Items.AddRange(New String() {"11111", "22222", "33333", "44444", "55555", "66666"}) radioGroupCell2.CheckAlign = ContentAlignment.MiddleLeft '6 radio will be lay out to 3 columns. radioGroupCell2.ColumnCount = 3 'The radio button will range from top to bottom. radioGroupCell2.FlowDirection = Orientation.Vertical 'Between every 2 lines, 20 pixels space exists at least. radioGroupCell2.VerticalSpace = 20 ' radioGroupCell2.Ellipsis = MultiRowEllipsisMode.EllipsisEnd radioGroupCell2.EllipsisString = "..." Dim template1 As Template = Template.CreateGridTemplate(New Cell() {radioGroupCell1, radioGroupCell2}) gcMultiRow1.Template = template1 gcMultiRow1.RowCount = 3 End Sub Private Sub gcMultiRow1_CellEditedFormattedValueChanged(ByVal sender As Object, ByVal e As CellEditedFormattedValueChangedEventArgs) Handles gcMultiRow1.CellEditedFormattedValueChanged Dim itemIndex As Integer = DirectCast((Me.gcMultiRow1.GetEditedFormattedValue(e.RowIndex, e.CellIndex)), Integer) Me.label.Text = "The clicked item is " + TryCast(Me.gcMultiRow1.CurrentCell, RadioGroupCell).Items(itemIndex) End Sub <STAThreadAttribute()> _ Public Shared Sub Main() Application.EnableVisualStyles() Application.Run(New RadioGroupCellDemo()) End Sub End Class
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
GrapeCity.Win.MultiRow.Cell
GrapeCity.Win.MultiRow.RadioGroupCell