Imports System.Data.OleDb
Imports System.IO

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents C1ExpressConnection1 As C1.Data.Express.C1ExpressConnection
    Friend WithEvents C1ExpressTable1 As C1.Data.Express.C1ExpressTable
    Friend WithEvents C1ExpressTable2 As C1.Data.Express.C1ExpressTable
    Friend WithEvents C1TrueDBGrid1 As C1.Win.C1TrueDBGrid.C1TrueDBGrid
    Friend WithEvents C1TrueDBGrid2 As C1.Win.C1TrueDBGrid.C1TrueDBGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
        Me.C1ExpressConnection1 = New C1.Data.Express.C1ExpressConnection
        Me.C1ExpressTable1 = New C1.Data.Express.C1ExpressTable
        Me.C1ExpressTable2 = New C1.Data.Express.C1ExpressTable
        Me.C1TrueDBGrid1 = New C1.Win.C1TrueDBGrid.C1TrueDBGrid
        Me.C1TrueDBGrid2 = New C1.Win.C1TrueDBGrid.C1TrueDBGrid
        CType(Me.C1ExpressConnection1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.C1ExpressTable1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.C1ExpressTable2, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.C1TrueDBGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.C1TrueDBGrid2, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'C1ExpressConnection1
        '
        Me.C1ExpressConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\ComponentOne Studio" & _
            ".NET 2.0\common\Nwind.mdb;Persist Security Info=False"
        Me.C1ExpressConnection1.DummyImage = CType(resources.GetObject("C1ExpressConnection1.DummyImage"), System.Drawing.Bitmap)
        Me.C1ExpressConnection1.Locale = New System.Globalization.CultureInfo("en-US")
        Me.C1ExpressConnection1.SerializedRelations = resources.GetString("C1ExpressConnection1.SerializedRelations")
        Me.C1ExpressConnection1.SerializedSchemaXML = Me.C1ExpressConnection1.GetSchemaFromResources(resources, "C1ExpressConnection1", Me)
        '
        'C1ExpressTable1
        '
        Me.C1ExpressTable1.BindingContextCtrl = Me
        Me.C1ExpressTable1.ConnectionComponent = Me.C1ExpressConnection1
        Me.C1ExpressTable1.ConnectionString = ""
        Me.C1ExpressTable1.DummyImage = CType(resources.GetObject("C1ExpressTable1.DummyImage"), System.Drawing.Bitmap)
        Me.C1ExpressTable1.FullComponentName = "Form1.C1ExpressTable1"
        Me.C1ExpressTable1.SchemaTableName = "Customers"
        Me.C1ExpressTable1.TableViewName = "Customers"
        Me.C1ExpressTable1.SerializedSchemaXML = Me.C1ExpressTable1.GetSchemaFromResources(resources, "C1ExpressTable1", Me)
        '
        'C1ExpressTable2
        '
        Me.C1ExpressTable2.BindingContextCtrl = Me
        Me.C1ExpressTable2.ConnectionComponent = Me.C1ExpressConnection1
        Me.C1ExpressTable2.ConnectionString = ""
        Me.C1ExpressTable2.DummyImage = CType(resources.GetObject("C1ExpressTable2.DummyImage"), System.Drawing.Bitmap)
        Me.C1ExpressTable2.FullComponentName = "Form1.C1ExpressTable2"
        Me.C1ExpressTable2.SchemaTableName = "Orders"
        Me.C1ExpressTable2.TableViewName = "Orders"
        Me.C1ExpressTable2.SerializedSchemaXML = Me.C1ExpressTable2.GetSchemaFromResources(resources, "C1ExpressTable2", Me)
        '
        'C1TrueDBGrid1
        '
        Me.C1TrueDBGrid1.DataMember = "_Customers"
        Me.C1TrueDBGrid1.DataSource = Me.C1ExpressConnection1
        Me.C1TrueDBGrid1.GroupByCaption = "Drag a column header here to group by that column"
        Me.C1TrueDBGrid1.Images.Add(CType(resources.GetObject("C1TrueDBGrid1.Images"), System.Drawing.Image))
        Me.C1TrueDBGrid1.Location = New System.Drawing.Point(8, 16)
        Me.C1TrueDBGrid1.Name = "C1TrueDBGrid1"
        Me.C1TrueDBGrid1.PreviewInfo.Location = New System.Drawing.Point(0, 0)
        Me.C1TrueDBGrid1.PreviewInfo.Size = New System.Drawing.Size(0, 0)
        Me.C1TrueDBGrid1.PreviewInfo.ZoomFactor = 75
        Me.C1TrueDBGrid1.PrintInfo.PageSettings = CType(resources.GetObject("C1TrueDBGrid1.PrintInfo.PageSettings"), System.Drawing.Printing.PageSettings)
        Me.C1TrueDBGrid1.Size = New System.Drawing.Size(640, 184)
        Me.C1TrueDBGrid1.TabIndex = 0
        Me.C1TrueDBGrid1.Text = "C1TrueDBGrid1"
        Me.C1TrueDBGrid1.PropBag = resources.GetString("C1TrueDBGrid1.PropBag")
        '
        'C1TrueDBGrid2
        '
        Me.C1TrueDBGrid2.DataMember = "_Customers.Customers - Orders"
        Me.C1TrueDBGrid2.DataSource = Me.C1ExpressConnection1
        Me.C1TrueDBGrid2.GroupByCaption = "Drag a column header here to group by that column"
        Me.C1TrueDBGrid2.Images.Add(CType(resources.GetObject("C1TrueDBGrid2.Images"), System.Drawing.Image))
        Me.C1TrueDBGrid2.Location = New System.Drawing.Point(8, 216)
        Me.C1TrueDBGrid2.Name = "C1TrueDBGrid2"
        Me.C1TrueDBGrid2.PreviewInfo.Location = New System.Drawing.Point(0, 0)
        Me.C1TrueDBGrid2.PreviewInfo.Size = New System.Drawing.Size(0, 0)
        Me.C1TrueDBGrid2.PreviewInfo.ZoomFactor = 75
        Me.C1TrueDBGrid2.PrintInfo.PageSettings = CType(resources.GetObject("C1TrueDBGrid2.PrintInfo.PageSettings"), System.Drawing.Printing.PageSettings)
        Me.C1TrueDBGrid2.Size = New System.Drawing.Size(640, 184)
        Me.C1TrueDBGrid2.TabIndex = 1
        Me.C1TrueDBGrid2.Text = "C1TrueDBGrid2"
        Me.C1TrueDBGrid2.PropBag = resources.GetString("C1TrueDBGrid2.PropBag")
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(664, 421)
        Me.Controls.Add(Me.C1TrueDBGrid2)
        Me.Controls.Add(Me.C1TrueDBGrid1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.C1ExpressConnection1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.C1ExpressTable1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.C1ExpressTable2, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.C1TrueDBGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.C1TrueDBGrid2, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

#Region " Switch to C1NWind.mdb database "

    Private Sub C1ExpressConnection1_BeforeFill(ByVal sender As System.Object, ByVal e As C1.Data.FillEventArgs) Handles C1ExpressConnection1.BeforeFill
        If Not C1ExpressConnection1.DataSet.Filled Then
            UpdateDbPath()
        End If
    End Sub

    Private Sub UpdateDbPath()
        Dim dbPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + _
            "\ComponentOne Samples\Common\C1NWind.mdb"
        If File.Exists(dbPath) Then
            Dim csb As New OleDbConnectionStringBuilder(C1ExpressConnection1.ConnectionString)
            csb.DataSource = dbPath
            C1ExpressConnection1.ConnectionString = csb.ToString()
        End If
    End Sub

#End Region

End Class
