Hey guys,
I have a program I wrote a few years back and I brought it back to life with a search feature. I am using an XML file to store the data in. I have a search function that will display the first result from the textbox1.text value, it displays it in a messagebox. What I want to do is display all the results in a datagrid. Here is the code I have now.
Is there a way to modify this code to show multiple results in a datagrid? For example, you have a locomotive and rolling stock named Santa Fe. I want to return all results for Santa Fe.Code:Imports System.Xml Public Class search Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim xmlFile As XmlReader xmlFile = XmlReader.Create(My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\train.xml", New XmlReaderSettings()) Dim ds As New DataSet Dim dv As New DataView ds.ReadXml(xmlFile) dv = New DataView(ds.Tables(0)) dv.Sort = "Name" Dim index As Integer = dv.Find(TextBox1.Text) If index = -1 Then MsgBox("Item Not Found") Else MsgBox(dv(index)("Name").ToString() & " " & dv(index)("type").ToString() & " " & dv(index)("Qty").ToString() & " " & dv(index)("Scale").ToString()) End If xmlFile.Close() End Sub Private Sub search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class
Tfairris


Reply With Quote