Public Class Form1
  Inherits System.Windows.Forms.Form
  Private swimmers As ArrayList
  Private tadapter As TreeAdapter

  Private Sub init()
    swimmers = New ArrayList()
    tadapter = New TreeAdapter(trKids)
    ReadFile()
  End Sub
#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
    init()
  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
  Friend WithEvents lsKids As System.Windows.Forms.ListBox
  Friend WithEvents trKids As System.Windows.Forms.TreeView
  Friend WithEvents btMove As System.Windows.Forms.Button

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

  '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.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.btMove = New System.Windows.Forms.Button()
    Me.lsKids = New System.Windows.Forms.ListBox()
    Me.trKids = New System.Windows.Forms.TreeView()
    Me.SuspendLayout()
    '
    'btMove
    '
    Me.btMove.Location = New System.Drawing.Point(144, 56)
    Me.btMove.Name = "btMove"
    Me.btMove.Size = New System.Drawing.Size(56, 24)
    Me.btMove.TabIndex = 2
    Me.btMove.Text = ">>"
    '
    'lsKids
    '
    Me.lsKids.Location = New System.Drawing.Point(8, 24)
    Me.lsKids.Name = "lsKids"
    Me.lsKids.Size = New System.Drawing.Size(128, 160)
    Me.lsKids.TabIndex = 0
    '
    'trKids
    '
    Me.trKids.ImageIndex = -1
    Me.trKids.Location = New System.Drawing.Point(216, 24)
    Me.trKids.Name = "trKids"
    Me.trKids.SelectedImageIndex = -1
    Me.trKids.Size = New System.Drawing.Size(152, 176)
    Me.trKids.TabIndex = 1
    '
    'Form1
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(384, 245)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btMove, Me.trKids, Me.lsKids})
    Me.Name = "Form1"
    Me.Text = "TreeAdapter"
    Me.ResumeLayout(False)

  End Sub

#End Region
  Private Sub ReadFile()
    Dim s As String
    Dim sw As Swimmer
    Dim fl As New vbFile("swimmers.txt")
    fl.OpenForRead()
    s = fl.readLine
    While Not fl.fEOF
      sw = New Swimmer(s)
      swimmers.Add(sw)
      lsKids.Items.Add(sw.getName)
      s = fl.readLine
    End While
  End Sub

  Private Sub btMove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btMove.Click
    Dim i As Integer
    Dim sw As Swimmer
    i = lsKids.SelectedIndex
    sw = CType(swimmers(i), Swimmer)
    tadapter.addText(sw)
  End Sub
End Class
