using System;
using System.Windows.Forms;
using System.Drawing;
namespace GrapeCity.Win.MultiRow.SampleCode
{
class CreateGridTemplateDemo:Form
{
private GcMultiRow gcMultiRow1 = new GcMultiRow();
private FlowLayoutPanel panel = new FlowLayoutPanel();
public CreateGridTemplateDemo()
{
this.Text = "CreateGridTemplate Demo";
this.Size = new Size(1000, 750);
// Initial flow layout panel and add to form.
this.panel.Dock = DockStyle.Left;
this.panel.Size = new Size(450, 200);
this.panel.FlowDirection = FlowDirection.TopDown;
this.panel.WrapContents = false;
this.panel.Padding = new Padding(5);
this.panel.AutoSize = true;
this.Controls.Add(panel);
this.gcMultiRow1.Dock = DockStyle.Left;
this.gcMultiRow1.Width = 550;
this.Controls.Add(this.gcMultiRow1);
this.Load += new EventHandler(Form1_Load);
InitButton();
this.StartPosition = FormStartPosition.CenterScreen;
}
private void Form1_Load(object sender, EventArgs e)
{
gcMultiRow1.Template = Template.Default;
gcMultiRow1.RowCount = 20;
}
#region Button Event Handlers
void setFirst_Click(object sender, EventArgs e)
{
Template template1 = Template.CreateGridTemplate(5);
this.gcMultiRow1.Template = template1;
}
void setSecond_Click(object sender, EventArgs e)
{
Template template1 = Template.CreateGridTemplate(5, 100, 25);
this.gcMultiRow1.Template = template1;
}
void setThird_Click(object sender, EventArgs e)
{
Template template1 = Template.CreateGridTemplate(8, 100, 25, 400, AutoGenerateGridTemplateStyles.RowHeaderAutoNumber | AutoGenerateGridTemplateStyles.ColumnHeader, 50);
this.gcMultiRow1.Template = template1;
}
void SetFourth_Click(object sender, EventArgs e)
{
NumericUpDownCell numericUpDownCell1 = new NumericUpDownCell();
numericUpDownCell1.Value = 0;
NumericUpDownCell numericUpDownCell2 = new NumericUpDownCell();
numericUpDownCell2.Value = 16m;
Template template1 = Template.CreateGridTemplate(new Cell[] { numericUpDownCell1, numericUpDownCell2 }, Int32.MaxValue,
AutoGenerateGridTemplateStyles.ColumnHeader | AutoGenerateGridTemplateStyles.RowHeaderAutoNumber, 50);
template1.ColumnHeaders[0].Cells[0].Value = "Column1";
template1.ColumnHeaders[0].Cells[1].Value = "Column2";
gcMultiRow1.Template = template1;
gcMultiRow1.RowCount = 10;
}
#endregion
#region Initialize Buttons
private void InitButton()
{
AddButton(setFirst, "CreateGridTemplate(int)", new EventHandler(setFirst_Click));
AddButton(setSecond, "CreateGridTemplate(int,int,int)", new EventHandler(setSecond_Click));
AddButton(setThird, "CreateGridTemplate(int,int,int,int,AutoGenerateGridTemplateStyles,int)", new EventHandler(setThird_Click));
AddButton(setFourth, "CreateGridTemplate(IEnumerable<Cell>,int,AutoGenerateGridTemplateStyles,int)", new EventHandler(SetFourth_Click));
}
private void AddButton(Button button, string text, EventHandler eventHandler)
{
this.panel.Controls.Add(button);
button.Text = text;
button.AutoSize = true;
button.Click += eventHandler;
}
Button setFirst = new Button();
Button setSecond = new Button();
Button setThird = new Button();
Button setFourth = new Button();
#endregion
[STAThreadAttribute()]
public static void Main()
{
Application.EnableVisualStyles();
Application.Run(new CreateGridTemplateDemo());
}
}
}
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports GrapeCity.Win.MultiRow
Class CreateGridTemplateDemo
Inherits Form
Private gcMultiRow1 As New GcMultiRow()
Private panel As New FlowLayoutPanel()
Public Sub New()
Me.Text = "CreateGridTemplate Demo"
Me.Size = New Size(1000, 750)
' Initial flow layout panel and add to form.
Me.panel.Dock = DockStyle.Left
Me.panel.Size = New Size(450, 200)
Me.panel.FlowDirection = FlowDirection.TopDown
Me.panel.WrapContents = False
Me.panel.Padding = New Padding(5)
Me.panel.AutoSize = True
Me.Controls.Add(panel)
Me.gcMultiRow1.Dock = DockStyle.Left
Me.gcMultiRow1.Width = 550
Me.Controls.Add(Me.gcMultiRow1)
InitButton()
Me.StartPosition = FormStartPosition.CenterScreen
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
gcMultiRow1.Template = Template.Default
gcMultiRow1.RowCount = 20
End Sub
#Region "Button Event Handlers"
Private Sub setFirst_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setFirst.Click
Dim template1 As Template = Template.CreateGridTemplate(5)
Me.gcMultiRow1.Template = template1
End Sub
Private Sub setSecond_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setSecond.Click
Dim template1 As Template = Template.CreateGridTemplate(5, 100, 25)
Me.gcMultiRow1.Template = template1
End Sub
Private Sub setThird_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setThird.Click
Dim template1 As Template = Template.CreateGridTemplate(8, 100, 25, 400, AutoGenerateGridTemplateStyles.RowHeaderAutoNumber Or AutoGenerateGridTemplateStyles.ColumnHeader, 50)
Me.gcMultiRow1.Template = template1
End Sub
Private Sub SetFourth_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setFourth.Click
Dim numericUpDownCell1 As New NumericUpDownCell()
numericUpDownCell1.Value = 0
Dim numericUpDownCell2 As New NumericUpDownCell()
numericUpDownCell2.Value = 16D
Dim template1 As Template = Template.CreateGridTemplate(New Cell() {numericUpDownCell1, numericUpDownCell2}, Int32.MaxValue, AutoGenerateGridTemplateStyles.ColumnHeader Or AutoGenerateGridTemplateStyles.RowHeaderAutoNumber, 50)
template1.ColumnHeaders(0).Cells(0).Value = "Column1"
template1.ColumnHeaders(0).Cells(1).Value = "Column2"
gcMultiRow1.Template = template1
gcMultiRow1.RowCount = 10
End Sub
#End Region
#Region "Initialize Buttons"
Private Sub InitButton()
AddButton(setFirst, "CreateGridTemplate(int)")
AddButton(setSecond, "CreateGridTemplate(int,int,int)")
AddButton(setThird, "CreateGridTemplate(int,int,int,int,AutoGenerateGridTemplateStyles,int)")
AddButton(setFourth, "CreateGridTemplate(IEnumerable<Cell>,int,AutoGenerateGridTemplateStyles,int)")
End Sub
Private Sub AddButton(ByVal button As Button, ByVal text As String)
Me.panel.Controls.Add(button)
button.Text = text
button.AutoSize = True
End Sub
Friend WithEvents setFirst As New Button()
Friend WithEvents setSecond As New Button()
Friend WithEvents setThird As New Button()
Friend WithEvents setFourth As New Button()
#End Region
<STAThreadAttribute()> _
Public Shared Sub Main()
Application.EnableVisualStyles()
Application.Run(New CreateGridTemplateDemo())
End Sub
End Class