Imports System.Data
Imports System.Windows.Forms
Imports FarPoint.Win.Spread
Imports FarPoint.Win.Spread.Data
Imports FarPoint.Win.Spread.Model
Imports Spread.Common.DataStore
Imports Spread.Common.Features.Spread.Common.Features.Sample

Namespace Features
    Partial Public Class CustomTable
        Inherits BaseSampleControl
#Region "Fields"
        Private isTableSelected As Boolean
        Private _dataSource As AccessDataSource
        Private Shared tableNumber As Integer = 2
#End Region

#Region "ctor"
        Public Sub New()
            InitializeComponent()
            Name = "Custom Table"

            _dataSource = New DataService().AccessDataSource

            pnlControls.HorizontalScroll.Maximum = 0
            pnlControls.AutoScroll = False
            pnlControls.VerticalScroll.Visible = False
            pnlControls.AutoScroll = True

            SetSheetProperties(fpSpread.ActiveSheet)
            AddSampleTable(fpSpread.ActiveSheet)
            AddHandler fpSpread.SelectionChanged, AddressOf FpSpread_SelectionChanged

            AddHandler txtColumnFrom.TextChanged, AddressOf MoveTableColumnParametersChanged
            AddHandler txtColumnTo.TextChanged, AddressOf MoveTableColumnParametersChanged
            AddHandler txtColMoveCount.TextChanged, AddressOf MoveTableColumnParametersChanged

            AddHandler txtRowFrom.TextChanged, AddressOf MoveTableRowParametersChanged
            AddHandler txtRowTo.TextChanged, AddressOf MoveTableRowParametersChanged
            AddHandler txtRowMoveCount.TextChanged, AddressOf MoveTableRowParametersChanged

            AddHandler txtRowCount.TextChanged, AddressOf ResizeTableParametersChanged
            AddHandler txtColumnCount.TextChanged, AddressOf ResizeTableParametersChanged

            AddHandler btnMoveRows.Click, AddressOf BtnMoveRows_Click
            AddHandler btnMoveCols.Click, AddressOf BtnMoveCols_Click
            AddHandler btnAddTable.Click, AddressOf BtnAddTable_Click
            AddHandler btnRemoveTable.Click, AddressOf BtnRemoveTable_Click
            AddHandler btnResizeTable.Click, AddressOf BtnResizeTable_Click
        End Sub
#End Region

#Region "Private methods"
        Private Sub SetSheetProperties(sheet As SheetView)
            fpSpread.StatusBarVisible = True
            sheet.SetMultipleRowHeights(0, sheet.RowCount, 20)
        End Sub

        Private Sub AddSampleTable(sheet As SheetView)
            Dim dataTable As DataTable = _dataSource.GetDataFromTable("Nwind.mdb", "Products").Tables(0)
            Dim adapter As New SpreadDataBindingAdapter()
            adapter.Spread = fpSpread
            adapter.SheetName = "Sheet1"
            adapter.DataSource = dataTable
            adapter.MapperInfo = New MapperInfo(2, 1, 30, dataTable.Columns.Count)
            adapter.FillSpreadDataByDataSource()

            Dim col As Integer = 1
            For Each column As DataColumn In dataTable.Columns
                sheet.Cells(1, System.Math.Max(System.Threading.Interlocked.Increment(col), col - 1)).Text = (column.Caption)
            Next

            Dim table As TableView = sheet.AddTable("Table1", 1, 1, 31, dataTable.Columns.Count, TableStyle.TableStyleMedium2)

            For j As Integer = 1 To col - 1
                sheet.Columns(j).Width = sheet.Columns(j).GetPreferredWidth()
            Next
        End Sub

        Private Sub ToggleButtons()
            Dim range As CellRange = fpSpread.ActiveSheet.GetSelection(0)
            Dim table As TableView = fpSpread.ActiveSheet.GetTable(range.Row, range.Column)
            isTableSelected = table IsNot Nothing
            txtTableName.Text = If(isTableSelected, table.Name, String.Empty)
            btnRemoveTable.Enabled = isTableSelected
            btnAddTable.Enabled = Not isTableSelected

            ToggleButtonState(btnMoveRows, txtRowFrom, txtRowTo, txtRowMoveCount)
            ToggleButtonState(btnMoveCols, txtColumnFrom, txtColumnTo, txtColMoveCount)
            ToggleButtonState(btnResizeTable, txtRowCount, txtColumnCount)
        End Sub

        Private Sub ToggleButtonState(button As Button, ParamArray textBoxes As TextBox())
            For Each textBox As Object In textBoxes
                Dim value As Integer = 0
                If textBox.Text = String.Empty OrElse Not Integer.TryParse(textBox.Text, value) Then
                    button.Enabled = False
                    Return
                End If
            Next
            button.Enabled = isTableSelected
        End Sub
#End Region

#Region "Event handlers"
        Private Sub FpSpread_SelectionChanged(sender As Object, e As SelectionChangedEventArgs)
            ToggleButtons()
        End Sub

        Private Sub BtnAddTable_Click(sender As Object, e As EventArgs)
            Dim range As CellRange = fpSpread.ActiveSheet.GetSelection(0)
            If range Is Nothing Then
                MessageBox.Show("Select a valid cell range", "Invalid Selection", MessageBoxButtons.OK, MessageBoxIcon.Information)
                Return
            End If
            Dim tableName As String = txtTableName.Text
            If tableName = String.Empty Then
                tableName = "Table{tableNumber++}"
            End If

            Try
                fpSpread.ActiveSheet.AddTable(tableName, range.Row, range.Column, range.RowCount, range.ColumnCount, TableStyle.TableStyleLight1)
                txtTableName.Text = tableName
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error adding table", MessageBoxButtons.OK, MessageBoxIcon.[Error])
            End Try
        End Sub

        Private Sub BtnRemoveTable_Click(sender As Object, e As EventArgs)
            Dim activeCell As Cell = fpSpread.ActiveSheet.ActiveCell
            Dim table As TableView = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index)
            Dim range As CellRange = table.DataRange
            fpSpread.ActiveSheet.RemoveTable(table.Name)
            ToggleButtons()

            fpSpread.ActiveSheet.Cells(range.Row, range.Column, range.Row + range.RowCount - 1, range.Column + range.ColumnCount - 1).ResetValue()
        End Sub

        Private Sub BtnMoveRows_Click(sender As Object, e As EventArgs)
            Dim rowFrom As Integer = Integer.Parse(txtRowFrom.Text)
            Dim rowTo As Integer = Integer.Parse(txtRowTo.Text)
            Dim rowCount As Integer = Integer.Parse(txtRowMoveCount.Text)

            Dim activeCell As Cell = fpSpread.ActiveSheet.ActiveCell
            Dim table As TableView = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index)

            Try
                table.MoveTableRows(rowFrom, rowTo, rowCount)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error moving rows", MessageBoxButtons.OK, MessageBoxIcon.[Error])
            End Try
        End Sub

        Private Sub BtnMoveCols_Click(sender As Object, e As EventArgs)
            Dim colFrom As Integer = Integer.Parse(txtColumnFrom.Text)
            Dim colTo As Integer = Integer.Parse(txtColumnTo.Text)
            Dim colCount As Integer = Integer.Parse(txtColMoveCount.Text)

            Dim activeCell As Cell = fpSpread.ActiveSheet.ActiveCell
            Dim table As TableView = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index)

            Try
                table.MoveTableColumns(colFrom, colTo, colCount)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error moving columns", MessageBoxButtons.OK, MessageBoxIcon.[Error])
            End Try
        End Sub

        Private Sub BtnResizeTable_Click(sender As Object, e As EventArgs)
            Dim rowCount As Integer = Integer.Parse(txtRowCount.Text)
            Dim colCount As Integer = Integer.Parse(txtColumnCount.Text)
            Dim activeCell As Cell = fpSpread.ActiveSheet.ActiveCell
            Dim table As TableView = fpSpread.ActiveSheet.GetTable(activeCell.Row.Index, activeCell.Column.Index)

            Try
                table.Resize(rowCount, colCount)
                ToggleButtons()
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error resizing table", MessageBoxButtons.OK, MessageBoxIcon.[Error])
            End Try
        End Sub

        Private Sub MoveTableColumnParametersChanged(sender As Object, e As EventArgs)
            ToggleButtonState(btnMoveCols, txtColumnFrom, txtColumnTo, txtColMoveCount)
        End Sub

        Private Sub MoveTableRowParametersChanged(sender As Object, e As EventArgs)
            ToggleButtonState(btnMoveRows, txtRowFrom, txtRowTo, txtRowMoveCount)
        End Sub

        Private Sub ResizeTableParametersChanged(sender As Object, e As EventArgs)
            ToggleButtonState(btnResizeTable, txtRowCount, txtColumnCount)
        End Sub
#End Region
    End Class
End Namespace

'
'CustomTable.Designer.vb
'

Namespace Features
	Partial Class CustomTable
		''' <summary> 
		''' Required designer variable.
		''' </summary>
		Private components As System.ComponentModel.IContainer = Nothing

        ''' <summary> 
        ''' Clean up any resources being used.
        ''' </summary>
        ''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        Protected Overloads Sub Dispose(disposing As Boolean)
            If disposing AndAlso (components IsNot Nothing) Then
                components.Dispose()
            End If
            MyBase.Dispose(disposing)
        End Sub

#Region "Component Designer generated code"

        ''' <summary> 
        ''' Required method for Designer support - do not modify 
        ''' the contents of this method with the code editor.
        ''' </summary>
        Private Sub InitializeComponent()
			Me.fpSpread = New FarPoint.Win.Spread.FpSpread()
			Me.fpSpread_Sheet1 = New FarPoint.Win.Spread.SheetView()
			Me.label1 = New System.Windows.Forms.Label()
			Me.label2 = New System.Windows.Forms.Label()
			Me.txtTableName = New System.Windows.Forms.TextBox()
			Me.btnRemoveTable = New System.Windows.Forms.Button()
			Me.btnAddTable = New System.Windows.Forms.Button()
			Me.label3 = New System.Windows.Forms.Label()
			Me.label4 = New System.Windows.Forms.Label()
			Me.txtRowFrom = New System.Windows.Forms.TextBox()
			Me.label5 = New System.Windows.Forms.Label()
			Me.btnMoveRows = New System.Windows.Forms.Button()
			Me.txtColumnFrom = New System.Windows.Forms.TextBox()
			Me.label9 = New System.Windows.Forms.Label()
			Me.txtRowTo = New System.Windows.Forms.TextBox()
			Me.label10 = New System.Windows.Forms.Label()
			Me.txtRowMoveCount = New System.Windows.Forms.TextBox()
			Me.label11 = New System.Windows.Forms.Label()
			Me.label12 = New System.Windows.Forms.Label()
			Me.txtColumnTo = New System.Windows.Forms.TextBox()
			Me.label13 = New System.Windows.Forms.Label()
			Me.txtColMoveCount = New System.Windows.Forms.TextBox()
			Me.groupBox1 = New System.Windows.Forms.GroupBox()
			Me.label8 = New System.Windows.Forms.Label()
			Me.btnResizeTable = New System.Windows.Forms.Button()
			Me.label7 = New System.Windows.Forms.Label()
			Me.txtColumnCount = New System.Windows.Forms.TextBox()
			Me.txtRowCount = New System.Windows.Forms.TextBox()
			Me.btnMoveCols = New System.Windows.Forms.Button()
			Me.tableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
			Me.tableLayoutPanel2 = New System.Windows.Forms.TableLayoutPanel()
			Me.tableLayoutPanel3 = New System.Windows.Forms.TableLayoutPanel()
			Me.pnlMain.SuspendLayout()
			Me.pnlControls.SuspendLayout()
			DirectCast(Me.fpSpread, System.ComponentModel.ISupportInitialize).BeginInit()
			DirectCast(Me.fpSpread_Sheet1, System.ComponentModel.ISupportInitialize).BeginInit()
			Me.groupBox1.SuspendLayout()
			Me.tableLayoutPanel2.SuspendLayout()
			Me.tableLayoutPanel3.SuspendLayout()
			Me.SuspendLayout()
			' 
			' pnlMain
			' 
			Me.pnlMain.Controls.Add(Me.fpSpread)
			Me.pnlMain.Controls.Add(Me.tableLayoutPanel1)
			Me.pnlMain.Size = New System.Drawing.Size(456, 527)
			' 
			' pnlControls
			' 
			Me.pnlControls.Controls.Add(Me.tableLayoutPanel3)
			Me.pnlControls.Controls.Add(Me.tableLayoutPanel2)
			Me.pnlControls.Controls.Add(Me.btnMoveCols)
			Me.pnlControls.Controls.Add(Me.groupBox1)
			Me.pnlControls.Controls.Add(Me.txtColMoveCount)
			Me.pnlControls.Controls.Add(Me.label13)
			Me.pnlControls.Controls.Add(Me.txtRowMoveCount)
			Me.pnlControls.Controls.Add(Me.label10)
			Me.pnlControls.Controls.Add(Me.btnMoveRows)
			Me.pnlControls.Controls.Add(Me.label5)
			Me.pnlControls.Controls.Add(Me.label3)
			Me.pnlControls.Controls.Add(Me.btnAddTable)
			Me.pnlControls.Controls.Add(Me.btnRemoveTable)
			Me.pnlControls.Controls.Add(Me.txtTableName)
			Me.pnlControls.Controls.Add(Me.label2)
			Me.pnlControls.Controls.Add(Me.label1)
			Me.pnlControls.Size = New System.Drawing.Size(151, 527)
			' 
			' fpSpread
			' 
			Me.fpSpread.Dock = System.Windows.Forms.DockStyle.Fill
			Me.fpSpread.Location = New System.Drawing.Point(0, 0)
			Me.fpSpread.Name = "fpSpread"
			Me.fpSpread.Sheets.AddRange(New FarPoint.Win.Spread.SheetView() {Me.fpSpread_Sheet1})
			Me.fpSpread.Size = New System.Drawing.Size(456, 527)
			Me.fpSpread.TabIndex = 0
			' 
			' fpSpread_Sheet1
			' 
			Me.fpSpread_Sheet1.Reset()
			Me.fpSpread_Sheet1.SheetName = "Sheet1"
			' Formulas and custom names must be loaded with R1C1 reference style
			Me.fpSpread_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1
			Me.fpSpread_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1
			' 
			' label1
			' 
			Me.label1.AutoSize = True
			Me.label1.Location = New System.Drawing.Point(5, 24)
			Me.label1.Name = "label1"
			Me.label1.Size = New System.Drawing.Size(185, 13)
			Me.label1.TabIndex = 0
			Me.label1.Text = "Please select the table area on sheet:"
			' 
			' label2
			' 
			Me.label2.AutoSize = True
			Me.label2.Location = New System.Drawing.Point(5, 47)
			Me.label2.Name = "label2"
			Me.label2.Size = New System.Drawing.Size(68, 13)
			Me.label2.TabIndex = 1
			Me.label2.Text = "Table Name:"
			' 
			' txtTableName
			' 
			Me.txtTableName.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtTableName.Location = New System.Drawing.Point(7, 63)
			Me.txtTableName.Name = "txtTableName"
			Me.txtTableName.Size = New System.Drawing.Size(129, 20)
			Me.txtTableName.TabIndex = 2
			' 
			' btnRemoveTable
			' 
			Me.btnRemoveTable.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.btnRemoveTable.Enabled = False
			Me.btnRemoveTable.Location = New System.Drawing.Point(20, 89)
			Me.btnRemoveTable.Name = "btnRemoveTable"
			Me.btnRemoveTable.Size = New System.Drawing.Size(99, 23)
			Me.btnRemoveTable.TabIndex = 3
			Me.btnRemoveTable.Text = "Remove Table"
			Me.btnRemoveTable.UseVisualStyleBackColor = True
			' 
			' btnAddTable
			' 
			Me.btnAddTable.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.btnAddTable.Location = New System.Drawing.Point(20, 118)
			Me.btnAddTable.Name = "btnAddTable"
			Me.btnAddTable.Size = New System.Drawing.Size(99, 23)
			Me.btnAddTable.TabIndex = 4
			Me.btnAddTable.Text = "Add Table"
			Me.btnAddTable.UseVisualStyleBackColor = True
			' 
			' label3
			' 
			Me.label3.AutoSize = True
			Me.label3.Location = New System.Drawing.Point(5, 151)
			Me.label3.Name = "label3"
			Me.label3.Size = New System.Drawing.Size(67, 13)
			Me.label3.TabIndex = 5
			Me.label3.Text = "Move Rows:"
			' 
			' label4
			' 
			Me.label4.Anchor = System.Windows.Forms.AnchorStyles.Left
			Me.label4.AutoSize = True
			Me.label4.Location = New System.Drawing.Point(3, 8)
			Me.label4.Name = "label4"
			Me.label4.Size = New System.Drawing.Size(33, 13)
			Me.label4.TabIndex = 7
			Me.label4.Text = "From:"
			' 
			' txtRowFrom
			' 
			Me.txtRowFrom.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtRowFrom.Location = New System.Drawing.Point(45, 4)
			Me.txtRowFrom.Name = "txtRowFrom"
			Me.txtRowFrom.Size = New System.Drawing.Size(26, 20)
			Me.txtRowFrom.TabIndex = 6
			' 
			' label5
			' 
			Me.label5.AutoSize = True
			Me.label5.Location = New System.Drawing.Point(5, 260)
			Me.label5.Name = "label5"
			Me.label5.Size = New System.Drawing.Size(80, 13)
			Me.label5.TabIndex = 10
			Me.label5.Text = "Move Columns:"
			' 
			' btnMoveRows
			' 
			Me.btnMoveRows.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.btnMoveRows.Enabled = False
			Me.btnMoveRows.Location = New System.Drawing.Point(20, 228)
			Me.btnMoveRows.Name = "btnMoveRows"
			Me.btnMoveRows.Size = New System.Drawing.Size(99, 23)
			Me.btnMoveRows.TabIndex = 9
			Me.btnMoveRows.Text = "Move Rows"
			Me.btnMoveRows.UseVisualStyleBackColor = True
			' 
			' txtColumnFrom
			' 
			Me.txtColumnFrom.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtColumnFrom.Location = New System.Drawing.Point(45, 4)
			Me.txtColumnFrom.Name = "txtColumnFrom"
			Me.txtColumnFrom.Size = New System.Drawing.Size(26, 20)
			Me.txtColumnFrom.TabIndex = 11
			' 
			' label9
			' 
			Me.label9.Anchor = System.Windows.Forms.AnchorStyles.None
			Me.label9.AutoSize = True
			Me.label9.Location = New System.Drawing.Point(77, 8)
			Me.label9.Name = "label9"
			Me.label9.Size = New System.Drawing.Size(23, 13)
			Me.label9.TabIndex = 15
			Me.label9.Text = "To:"
			' 
			' txtRowTo
			' 
			Me.txtRowTo.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtRowTo.Location = New System.Drawing.Point(107, 4)
			Me.txtRowTo.Name = "txtRowTo"
			Me.txtRowTo.Size = New System.Drawing.Size(27, 20)
			Me.txtRowTo.TabIndex = 7
			' 
			' label10
			' 
			Me.label10.AutoSize = True
			Me.label10.Location = New System.Drawing.Point(5, 203)
			Me.label10.Name = "label10"
			Me.label10.Size = New System.Drawing.Size(38, 13)
			Me.label10.TabIndex = 17
			Me.label10.Text = "Count:"
			' 
			' txtRowMoveCount
			' 
			Me.txtRowMoveCount.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtRowMoveCount.Location = New System.Drawing.Point(50, 200)
			Me.txtRowMoveCount.Name = "txtRowMoveCount"
			Me.txtRowMoveCount.Size = New System.Drawing.Size(89, 20)
			Me.txtRowMoveCount.TabIndex = 8
			' 
			' label11
			' 
			Me.label11.Anchor = System.Windows.Forms.AnchorStyles.None
			Me.label11.AutoSize = True
			Me.label11.Location = New System.Drawing.Point(4, 8)
			Me.label11.Name = "label11"
			Me.label11.Size = New System.Drawing.Size(33, 13)
			Me.label11.TabIndex = 19
			Me.label11.Text = "From:"
			' 
			' label12
			' 
			Me.label12.Anchor = System.Windows.Forms.AnchorStyles.None
			Me.label12.AutoSize = True
			Me.label12.Location = New System.Drawing.Point(77, 8)
			Me.label12.Name = "label12"
			Me.label12.Size = New System.Drawing.Size(23, 13)
			Me.label12.TabIndex = 20
			Me.label12.Text = "To:"
			' 
			' txtColumnTo
			' 
			Me.txtColumnTo.Anchor = CType((System.Windows.Forms.AnchorStyles.Left Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtColumnTo.Location = New System.Drawing.Point(107, 4)
			Me.txtColumnTo.Name = "txtColumnTo"
			Me.txtColumnTo.Size = New System.Drawing.Size(27, 20)
			Me.txtColumnTo.TabIndex = 12
			' 
			' label13
			' 
			Me.label13.AutoSize = True
			Me.label13.Location = New System.Drawing.Point(5, 316)
			Me.label13.Name = "label13"
			Me.label13.Size = New System.Drawing.Size(38, 13)
			Me.label13.TabIndex = 22
			Me.label13.Text = "Count:"
			' 
			' txtColMoveCount
			' 
			Me.txtColMoveCount.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtColMoveCount.Location = New System.Drawing.Point(50, 313)
			Me.txtColMoveCount.Name = "txtColMoveCount"
			Me.txtColMoveCount.Size = New System.Drawing.Size(89, 20)
			Me.txtColMoveCount.TabIndex = 13
			' 
			' groupBox1
			' 
			Me.groupBox1.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.groupBox1.Controls.Add(Me.label8)
			Me.groupBox1.Controls.Add(Me.btnResizeTable)
			Me.groupBox1.Controls.Add(Me.label7)
			Me.groupBox1.Controls.Add(Me.txtColumnCount)
			Me.groupBox1.Controls.Add(Me.txtRowCount)
			Me.groupBox1.Location = New System.Drawing.Point(0, 380)
			Me.groupBox1.Name = "groupBox1"
			Me.groupBox1.Size = New System.Drawing.Size(139, 139)
			Me.groupBox1.TabIndex = 24
			Me.groupBox1.TabStop = False
			Me.groupBox1.Text = "Resize Table"
			' 
			' label8
			' 
			Me.label8.AutoSize = True
			Me.label8.Location = New System.Drawing.Point(5, 61)
			Me.label8.Name = "label8"
			Me.label8.Size = New System.Drawing.Size(75, 13)
			Me.label8.TabIndex = 19
			Me.label8.Text = "Column count:"
			' 
			' btnResizeTable
			' 
			Me.btnResizeTable.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.btnResizeTable.Enabled = False
			Me.btnResizeTable.Location = New System.Drawing.Point(20, 103)
			Me.btnResizeTable.Name = "btnResizeTable"
			Me.btnResizeTable.Size = New System.Drawing.Size(99, 23)
			Me.btnResizeTable.TabIndex = 17
			Me.btnResizeTable.Text = "Resize Table"
			Me.btnResizeTable.UseVisualStyleBackColor = True
			' 
			' label7
			' 
			Me.label7.AutoSize = True
			Me.label7.Location = New System.Drawing.Point(5, 23)
			Me.label7.Name = "label7"
			Me.label7.Size = New System.Drawing.Size(62, 13)
			Me.label7.TabIndex = 17
			Me.label7.Text = "Row count:"
			' 
			' txtColumnCount
			' 
			Me.txtColumnCount.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtColumnCount.Location = New System.Drawing.Point(8, 77)
			Me.txtColumnCount.Name = "txtColumnCount"
			Me.txtColumnCount.Size = New System.Drawing.Size(131, 20)
			Me.txtColumnCount.TabIndex = 16
			' 
			' txtRowCount
			' 
			Me.txtRowCount.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.txtRowCount.Location = New System.Drawing.Point(8, 39)
			Me.txtRowCount.Name = "txtRowCount"
			Me.txtRowCount.Size = New System.Drawing.Size(131, 20)
			Me.txtRowCount.TabIndex = 15
			' 
			' btnMoveCols
			' 
			Me.btnMoveCols.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.btnMoveCols.Enabled = False
			Me.btnMoveCols.Location = New System.Drawing.Point(20, 340)
			Me.btnMoveCols.Name = "btnMoveCols"
			Me.btnMoveCols.Size = New System.Drawing.Size(99, 23)
			Me.btnMoveCols.TabIndex = 14
			Me.btnMoveCols.Text = "Move Columns"
			Me.btnMoveCols.UseVisualStyleBackColor = True
			' 
			' tableLayoutPanel1
			' 
			Me.tableLayoutPanel1.ColumnCount = 2
			Me.tableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel1.Location = New System.Drawing.Point(237, 219)
			Me.tableLayoutPanel1.Name = "tableLayoutPanel1"
			Me.tableLayoutPanel1.RowCount = 2
			Me.tableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel1.Size = New System.Drawing.Size(200, 100)
			Me.tableLayoutPanel1.TabIndex = 16
			' 
			' tableLayoutPanel2
			' 
			Me.tableLayoutPanel2.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.tableLayoutPanel2.ColumnCount = 4
			Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 42F))
			Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F))
			Me.tableLayoutPanel2.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel2.Controls.Add(Me.txtRowTo, 3, 0)
			Me.tableLayoutPanel2.Controls.Add(Me.label9, 2, 0)
			Me.tableLayoutPanel2.Controls.Add(Me.label4, 0, 0)
			Me.tableLayoutPanel2.Controls.Add(Me.txtRowFrom, 1, 0)
			Me.tableLayoutPanel2.Location = New System.Drawing.Point(5, 165)
			Me.tableLayoutPanel2.Name = "tableLayoutPanel2"
			Me.tableLayoutPanel2.RowCount = 1
			Me.tableLayoutPanel2.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F))
			Me.tableLayoutPanel2.Size = New System.Drawing.Size(137, 29)
			Me.tableLayoutPanel2.TabIndex = 25
			' 
			' tableLayoutPanel3
			' 
			Me.tableLayoutPanel3.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Left) Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
			Me.tableLayoutPanel3.ColumnCount = 4
			Me.tableLayoutPanel3.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 42F))
			Me.tableLayoutPanel3.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel3.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F))
			Me.tableLayoutPanel3.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F))
			Me.tableLayoutPanel3.Controls.Add(Me.label11, 0, 0)
			Me.tableLayoutPanel3.Controls.Add(Me.txtColumnFrom, 1, 0)
			Me.tableLayoutPanel3.Controls.Add(Me.label12, 2, 0)
			Me.tableLayoutPanel3.Controls.Add(Me.txtColumnTo, 3, 0)
			Me.tableLayoutPanel3.Location = New System.Drawing.Point(5, 278)
			Me.tableLayoutPanel3.Name = "tableLayoutPanel3"
			Me.tableLayoutPanel3.RowCount = 1
			Me.tableLayoutPanel3.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F))
			Me.tableLayoutPanel3.Size = New System.Drawing.Size(137, 29)
			Me.tableLayoutPanel3.TabIndex = 17
			' 
			' CustomTable
			' 
			Me.AutoScaleDimensions = New System.Drawing.SizeF(6F, 13F)
			Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
			Me.Name = "CustomTable"
			Me.Size = New System.Drawing.Size(608, 527)
			Me.pnlMain.ResumeLayout(False)
			Me.pnlControls.ResumeLayout(False)
			Me.pnlControls.PerformLayout()
			DirectCast(Me.fpSpread, System.ComponentModel.ISupportInitialize).EndInit()
			DirectCast(Me.fpSpread_Sheet1, System.ComponentModel.ISupportInitialize).EndInit()
			Me.groupBox1.ResumeLayout(False)
			Me.groupBox1.PerformLayout()
			Me.tableLayoutPanel2.ResumeLayout(False)
			Me.tableLayoutPanel2.PerformLayout()
			Me.tableLayoutPanel3.ResumeLayout(False)
			Me.tableLayoutPanel3.PerformLayout()
			Me.ResumeLayout(False)

		End Sub

		#End Region

		Private fpSpread As FarPoint.Win.Spread.FpSpread
		Private fpSpread_Sheet1 As FarPoint.Win.Spread.SheetView
		Private btnMoveRows As System.Windows.Forms.Button
		Private label5 As System.Windows.Forms.Label
		Private txtColumnFrom As System.Windows.Forms.TextBox
		Private txtRowFrom As System.Windows.Forms.TextBox
		Private label4 As System.Windows.Forms.Label
		Private label3 As System.Windows.Forms.Label
		Private btnAddTable As System.Windows.Forms.Button
		Private btnRemoveTable As System.Windows.Forms.Button
		Private txtTableName As System.Windows.Forms.TextBox
		Private label2 As System.Windows.Forms.Label
		Private label1 As System.Windows.Forms.Label
		Private txtRowTo As System.Windows.Forms.TextBox
		Private label9 As System.Windows.Forms.Label
		Private txtColMoveCount As System.Windows.Forms.TextBox
		Private label13 As System.Windows.Forms.Label
		Private txtColumnTo As System.Windows.Forms.TextBox
		Private label12 As System.Windows.Forms.Label
		Private label11 As System.Windows.Forms.Label
		Private txtRowMoveCount As System.Windows.Forms.TextBox
		Private label10 As System.Windows.Forms.Label
		Private btnMoveCols As System.Windows.Forms.Button
		Private groupBox1 As System.Windows.Forms.GroupBox
		Private label8 As System.Windows.Forms.Label
		Private btnResizeTable As System.Windows.Forms.Button
		Private label7 As System.Windows.Forms.Label
		Private txtColumnCount As System.Windows.Forms.TextBox
		Private txtRowCount As System.Windows.Forms.TextBox
		Private tableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
		Private tableLayoutPanel2 As System.Windows.Forms.TableLayoutPanel
		Private tableLayoutPanel3 As System.Windows.Forms.TableLayoutPanel
	End Class
End Namespace
