PowerTools CalendarGrid for Windows Forms 1.0J
DataSource プロパティ (CalendarGcComboBoxCellType)
使用例 

データソースを取得または設定します。
構文
Public Property DataSource As Object
public object DataSource {get; set;}

プロパティ値

データソースを示す object
既定値は null 参照 (Visual Basicでは Nothing) です。
解説
データソースにはデータベース、Web サービス、またはオブジェクトを指定することが可能で、これらを使用してデータバインドコントロールを生成できます。DataSource プロパティが設定されている場合、項目コレクションは変更できません。
使用例
次のサンプルコードは、データバインディングの使用方法を示します。
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using GrapeCity.Win.CalendarGrid.InputMan;
using GrapeCity.Win.CalendarGrid;

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

        public GcComboBoxCellDatabindingDemo()
        {
            this.Text = "GcComboBoxCell Databinding Demo";
            this.Size = new Size(300, 250);

            // Add GcCalendarGrid to form
            this.gcCalendarGrid1.Dock = DockStyle.Fill;
            this.Controls.Add(this.gcCalendarGrid1);

            this.label.Dock = DockStyle.Bottom;
            this.label.Height = 50;
            this.label.BackColor = SystemColors.Info;
            this.label.Text = "The GcComboBoxCell can bind a DataTable, open the DropDownList, two columns data will display.";
            this.Controls.Add(label);

            this.Load += Form1_Load;

            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            CalendarGcComboBoxCellType gcComboBoxCell1 = new CalendarGcComboBoxCellType();
            gcComboBoxCell1.DropDown.Size = new Size(120, 80);
            //Set the DataSource.
            gcComboBoxCell1.DataSource = CreateDateTable1();

            CalendarTemplate template1 = CalendarTemplate.CreateDefaultTemplate();
            template1.Content[1, 0].CellType = gcComboBoxCell1;
            template1.Content[2, 0].CellType = gcComboBoxCell1.Clone();

            gcCalendarGrid1.Template = template1;
        }

        private DataTable CreateDateTable1()
        {
            DataTable table1 = new DataTable("Developer");

            DataColumn column1 = new DataColumn("Name", typeof(string));
            table1.Columns.Add(column1);
            DataColumn column2 = new DataColumn("Age", typeof(int));
            table1.Columns.Add(column2);

            table1.Rows.Add("Colin", 30);
            table1.Rows.Add("Robert", 25);
            table1.Rows.Add("Erwin", 20);
            return table1;
        }

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

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

        Public Sub New()
            Me.Text = "GcComboBoxCell Databinding Demo"
            Me.Size = New Size(300, 250)

            ' Add GcCalendarGrid to form
            Me.gcCalendarGrid1.Dock = DockStyle.Fill
            Me.Controls.Add(Me.gcCalendarGrid1)

            Me.label.Dock = DockStyle.Bottom
            Me.label.Height = 50
            Me.label.BackColor = SystemColors.Info
            Me.label.Text = "The GcComboBoxCell can bind a DataTable, open the DropDownList, two columns data will display."
            Me.Controls.Add(label)

            AddHandler Me.Load, AddressOf Form1_Load

            Me.StartPosition = FormStartPosition.CenterScreen
        End Sub

        Private Sub Form1_Load(sender As Object, e As EventArgs)
            Dim gcComboBoxCell1 As New CalendarGcComboBoxCellType()
            gcComboBoxCell1.DropDown.Size = New Size(120, 80)
            'Set the DataSource.
            gcComboBoxCell1.DataSource = CreateDateTable1()

            Dim template1 As CalendarTemplate = CalendarTemplate.CreateDefaultTemplate()
            template1.Content(1, 0).CellType = gcComboBoxCell1
            template1.Content(2, 0).CellType = gcComboBoxCell1.Clone()

            gcCalendarGrid1.Template = template1
        End Sub

        Private Function CreateDateTable1() As DataTable
            Dim table1 As New DataTable("Developer")

            Dim column1 As New DataColumn("Name", GetType(String))
            table1.Columns.Add(column1)
            Dim column2 As New DataColumn("Age", GetType(Integer))
            table1.Columns.Add(column2)

            table1.Rows.Add("Colin", 30)
            table1.Rows.Add("Robert", 25)
            table1.Rows.Add("Erwin", 20)
            Return table1
        End Function

        <STAThreadAttribute> _
        Public Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New GcComboBoxCellDatabindingDemo())
        End Sub
    End Class
End Namespace
参照

CalendarGcComboBoxCellType クラス
CalendarGcComboBoxCellType メンバ
DataMember プロパティ

 

 


© 2014 GrapeCity inc. All rights reserved.