ユーザーが選択肢のグループから1つのオプションを選択できる
Cellを表します。
次のサンプルコードは、
RadioGroupCellの持ついくつかの重要なプロパティを示します。Column1では、
ColumnCountを3に設定することで、6個のラジオボタンを3列に配置します。各ラジオボタンは左から右に並べ、隣接する2つの列の間には20ピクセル以上の間隔を空けます。Column2でも、6個のラジオボタンを3列に配置します。ラジオボタンを並べる方向は上から下にし、隣接する2つの行の間隔を20ピクセル以上にします。テキスト全体を表示できないため、
EllipsisStringが表示されます。
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