|
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form Vom Windows Form Designer generierter Code
Private xmlPath As String = _
System.Configuration.ConfigurationSettings. _
AppSettings.Get("xmlPath")
Dim ds As New DataSet
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Read_XMLFile(xmlPath)
End Sub
Private Sub Read_XMLFile(ByVal sFile As String)
Label1.Visible = True
Label1.Refresh()
Cursor = Cursors.WaitCursor
ds.Clear()
ListView1.Items.Clear()
ds.ReadXml(sFile)
RefreshResults("true")
Cursor = Cursors.Default
Label1.Visible = False
End Sub
Private Sub RefreshResults(ByVal filter As String)
Try
Dim table As DataTable = ds.Tables(0)
Dim rows As DataRow() = table.Select(filter)
For Each row As DataRow In rows
Dim item As ListViewItem = _
New ListViewItem(row("name").ToString())
item.SubItems.Add(row("vorname").ToString())
item.SubItems.Add(row("firma").ToString())
item.SubItems.Add(row("beruf").ToString())
item.SubItems.Add(row("strasse").ToString())
item.SubItems.Add(row("wohnort").ToString())
item.SubItems.Add(row("telefon").ToString())
ListView1.Items.Add(item)
Next
Catch e As Exception
MessageBox.Show(e.Message)
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Label2.Text = xmlPath
CreateListview()
End Sub
Private Sub CreateListview()
With ListView1
.View = View.Details
.Width = 745
.Columns.Add("name", 100, HorizontalAlignment.Left)
.Columns.Add("vorname", 100, HorizontalAlignment.Left)
.Columns.Add("firma", 110, HorizontalAlignment.Left)
.Columns.Add("beruf", 100, HorizontalAlignment.Left)
.Columns.Add("strasse", 100, HorizontalAlignment.Left)
.Columns.Add("wohnort", 120, HorizontalAlignment.Left)
.Columns.Add("telefon", 110, HorizontalAlignment.Left)
End With
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class
|
|