Imports System.Data.OleDb
Imports System.IO

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        textBox1.Text = c1DataViewSet1.Views(0).Definition
        checkBox1.Checked = c1TrueDBGrid1.UseColumnStyles
    End Sub

    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        c1TrueDBGrid1.ClearFields()
        c1DataViewSet1.Views(0).Definition = textBox1.Text
    End Sub

    Private Sub checkBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles checkBox1.CheckedChanged
        c1TrueDBGrid1.UseColumnStyles = checkBox1.Checked
    End Sub

    Private Sub c1DataViewSet1_ConnectionOpening(ByVal sender As System.Object, ByVal e As C1.C1DataExtender.ConnectionOpeningEventArgs) Handles c1DataViewSet1.ConnectionOpening
        Dim csb As New OleDbConnectionStringBuilder(e.Connection.ConnectionString)
        ' If connection string specified in application resources points to a non-existant database file
        ' then use a database from a default sample database location.
        If Not File.Exists(csb.DataSource) Then
            csb.DataSource = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), _
                     "ComponentOne Samples\Common\C1NWind.mdb")
            e.Connection.ConnectionString = csb.ToString()
        End If
    End Sub
End Class
