GrapeCity CalendarGrid for Windows Forms 2.0J
CalendarRadioGroupCellType クラス
メンバ  使用例 

ユーザーが選択肢のグループから 1 つのオプションを選択できる CalendarCellType を表します。
構文
Public Class CalendarRadioGroupCellType 
   Inherits CalendarCellType
public class CalendarRadioGroupCellType : CalendarCellType 
解説

CalendarRadioGroupCellType クラスは、ラジオボタンのセットを表示する特別なタイプの CalendarCellType です。CalendarRadioGroupCellType が現在のセルで、編集モードにある場合、ユーザーは単にクリックするか、[←]、[→]、[↑]、[↓]のいずれかのキーを押すことによって、セルの値を編集できます。

ユーザーが CalendarRadioGroupCellType のラジオボタンを選択すると、同じ CalendarRadioGroupCellType 内の他のラジオボタンの選択が解除されます。ラジオグループは、ユーザーに選択肢のセットを提示し、その中から 1 つだけ選択させる場合に定義します。

継承時の注意:

CalendarRadioGroupCellType から継承した派生クラスに新しいプロパティを追加するときは、必ず Clone メソッドをオーバーライドして、クローニング操作時に新しいプロパティがコピーされるようにしてください。また、基本クラスの Clone メソッドを呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにしてください。

使用例
次のサンプルコードは、CalendarRadioGroupCellType のいくつかの重要なプロパティを示します。最初のラジオグループでは、ColumnCount を 3 に設定して、6 個のラジオボタン項目を 3 列に配置しています。項目は左から右に並びます。20 ピクセルの列間隔を空けます。2 番目のラジオグループでは、6 個のラジオボタン項目を 3 列に配置しています。項目は上から下に並びます。20 ピクセルの行間隔を空けます。テキストは表示できないため、EllipsisString は表示されません。
using System;
using System.Windows.Forms;
using System.Drawing;
using GrapeCity.Win.CalendarGrid;

namespace CalendarGridSampleCode
{
    public class RadioGroupCellDemo : Form
    {
        private GcCalendarGrid gcCalendarGrid1 = new GcCalendarGrid();
        private Label label = new Label();

        public RadioGroupCellDemo()
        {
            this.Text = "RadioGroupCell Demo";
            this.gcCalendarGrid1.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.gcCalendarGrid1);
            this.Controls.Add(this.label);
            this.Load += Form1_Load;
            this.gcCalendarGrid1.CellEditingValueChanged += gcCalendarGrid1_CellEditingValueChanged;
            this.Size = new Size(400, 400);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            CalendarRadioGroupCellType radioGroupCell1 = new CalendarRadioGroupCellType();
            for (int i = 1; i < 7; i++)
            {
                radioGroupCell1.Items.Add(i.ToString());
            }
            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;

            CalendarRadioGroupCellType radioGroupCell2 = new CalendarRadioGroupCellType();
            radioGroupCell2.Items.Add("11111");
            radioGroupCell2.Items.Add("22222");
            radioGroupCell2.Items.Add("33333");
            radioGroupCell2.Items.Add("44444");
            radioGroupCell2.Items.Add("55555");
            radioGroupCell2.Items.Add("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 = CalendarGridEllipsisMode.EllipsisEnd;
            radioGroupCell2.EllipsisString = "...";

            CalendarTemplate template1 = CalendarTemplate.CreateDefaultTemplate();
            template1.Content.Columns[0].Width = 150;
            template1.Content.Rows[1].Height = 60;
            template1.Content.Rows[2].Height = 60;
            template1.Content[1, 0].CellType = radioGroupCell1;
            template1.Content[2, 0].CellType = radioGroupCell2;
            gcCalendarGrid1.Template = template1;
        }

        private void gcCalendarGrid1_CellEditingValueChanged(object sender, CalendarCellEditingValueChangedEventArgs e)
        {
            object item = (this.gcCalendarGrid1[e.CellPosition.Date][e.CellPosition.RowIndex, e.CellPosition.ColumnIndex].CellType as CalendarRadioGroupCellType).Items[(int)e.Value];
            this.label.Text = "The clicked item is " + item.ToString();
        }

        [STAThreadAttribute()]
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new RadioGroupCellDemo());
        }
    }
}
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.CalendarGrid

Namespace CalendarGridSampleCode
    Public Class RadioGroupCellDemo
        Inherits Form
        Private gcCalendarGrid1 As New GcCalendarGrid()
        Private label As New Label()

        Public Sub New()
            Me.Text = "RadioGroupCell Demo"
            Me.gcCalendarGrid1.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.gcCalendarGrid1)
            Me.Controls.Add(Me.label)
            AddHandler Me.Load, AddressOf Form1_Load
            AddHandler Me.gcCalendarGrid1.CellEditingValueChanged, AddressOf gcCalendarGrid1_CellEditingValueChanged
            Me.Size = New Size(400, 400)
        End Sub

        Private Sub Form1_Load(sender As Object, e As EventArgs)
            Dim radioGroupCell1 As New CalendarRadioGroupCellType()
            For i As Integer = 1 To 6
                radioGroupCell1.Items.Add(i.ToString())
            Next
            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 CalendarRadioGroupCellType()
            radioGroupCell2.Items.Add("11111")
            radioGroupCell2.Items.Add("22222")
            radioGroupCell2.Items.Add("33333")
            radioGroupCell2.Items.Add("44444")
            radioGroupCell2.Items.Add("55555")
            radioGroupCell2.Items.Add("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 = CalendarGridEllipsisMode.EllipsisEnd
            radioGroupCell2.EllipsisString = "..."

            Dim template1 As CalendarTemplate = CalendarTemplate.CreateDefaultTemplate()
            template1.Content.Columns(0).Width = 150
            template1.Content.Rows(1).Height = 60
            template1.Content.Rows(2).Height = 60
            template1.Content(1, 0).CellType = radioGroupCell1
            template1.Content(2, 0).CellType = radioGroupCell2
            gcCalendarGrid1.Template = template1
        End Sub

        Private Sub gcCalendarGrid1_CellEditingValueChanged(sender As Object, e As CalendarCellEditingValueChangedEventArgs)
            Dim item As Object = TryCast(Me.gcCalendarGrid1(e.CellPosition.[Date])(e.CellPosition.RowIndex, e.CellPosition.ColumnIndex).CellType, CalendarRadioGroupCellType).Items(CInt(e.Value))
            Me.label.Text = "The clicked item is " + item.ToString()
        End Sub

        <STAThreadAttribute> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New RadioGroupCellDemo())
        End Sub
    End Class
End Namespace
継承階層

System.Object
   GrapeCity.Win.CalendarGrid.CalendarCellType
      GrapeCity.Win.CalendarGrid.CalendarRadioGroupCellType

参照

CalendarRadioGroupCellType メンバ
GrapeCity.Win.CalendarGrid 名前空間

 

 


c 2008 GrapeCity inc. All rights reserved.