using System;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
namespace GrapeCity.Win.MultiRow.InputMan.SampleCode
{
class GcComboBoxCellDatabindingDemo : Form
{
private GcMultiRow gcMultiRow1 = new GcMultiRow();
private Label label = new Label();
public GcComboBoxCellDatabindingDemo()
{
this.Text = "GcComboBoxCell Databinding Demo";
this.Size = new Size(300, 250);
// Add MultiRow to form
this.gcMultiRow1.Dock = DockStyle.Fill;
this.Controls.Add(this.gcMultiRow1);
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 += new EventHandler(Form1_Load);
this.StartPosition = FormStartPosition.CenterScreen;
}
private void Form1_Load(object sender, EventArgs e)
{
GcComboBoxCell gcComboBoxCell1 = new GcComboBoxCell();
gcComboBoxCell1.DropDown.Size = new Size(120, 80);
//Set the DataSource.
gcComboBoxCell1.DataSource = CreateDateTable1();
Template template1 = Template.CreateGridTemplate(new Cell[] { gcComboBoxCell1, gcComboBoxCell1.Clone() as Cell }, 200,
AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber);
gcMultiRow1.Template = template1;
gcMultiRow1.RowCount = 3;
}
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
Imports System.Windows.Forms
Imports System.Drawing
Imports System.Data
Namespace GrapeCity.Win.MultiRow.InputMan.SampleCode
Class GcComboBoxCellDatabindingDemo
Inherits Form
Private gcMultiRow1 As New GcMultiRow()
Private label As New Label()
Public Sub New()
Me.Text = "GcComboBoxCell Databinding Demo"
Me.Size = New Size(300, 250)
' Add MultiRow to form
Me.gcMultiRow1.Dock = DockStyle.Fill
Me.Controls.Add(Me.gcMultiRow1)
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)
Me.StartPosition = FormStartPosition.CenterScreen
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim gcComboBoxCell1 As New GcComboBoxCell()
gcComboBoxCell1.DropDown.Size = New Size(120, 80)
'Set the DataSource.
gcComboBoxCell1.DataSource = CreateDateTable1()
Dim template1 As Template = Template.CreateGridTemplate(New Cell() {gcComboBoxCell1, TryCast(gcComboBoxCell1.Clone(), Cell)}, 200, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber)
gcMultiRow1.Template = template1
gcMultiRow1.RowCount = 3
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