A
Aaron
I have some code that is exactly the same as another area of my
program which is binding an xml doc to a listbox, yet in this case, it
doesn't work...no errors, just doesn't load any data!!!
I'm using C# and here's my code...
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.IO;
using System.Globalization;
..
..
..
DataSet toolDS;
string xmlFileName;
String strAppPath =
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
public frmDelete()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
// Create a new dataset.
toolDS = new DataSet();
// Set the Locale for the DataSet,
// using the current culture as the default
toolDS.Locale = CultureInfo.CurrentCulture;
// Set file names and create file streams.
// The XSD, XML, and EXE must be in the same directory.
xmlFileName = strAppPath + "\\Tools.xml";
FileStream FsXML = new FileStream(xmlFileName,FileMode.Open);
// Load the data into the DataSet.
XmlTextReader xtrXML = new XmlTextReader(FsXML);
toolDS.ReadXml(xtrXML);
xtrXML.Close();
FsXML.Close();
// Get a DataTable to conveniently use for binding.
DataTable dt = toolDS.Tables["Tools"];
//Bind the ListBox to the tools
lstTools.DataSource = dt;
lstTools.DisplayMember = "Tool";
}
My xml file...
<?xml version="1.0" encoding="utf-8" ?>
<Tools>
<Tool>Tool #1</Tool>
<Tool>Tool #2</Tool>
program which is binding an xml doc to a listbox, yet in this case, it
doesn't work...no errors, just doesn't load any data!!!
I'm using C# and here's my code...
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.IO;
using System.Globalization;
..
..
..
DataSet toolDS;
string xmlFileName;
String strAppPath =
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
public frmDelete()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
// Create a new dataset.
toolDS = new DataSet();
// Set the Locale for the DataSet,
// using the current culture as the default
toolDS.Locale = CultureInfo.CurrentCulture;
// Set file names and create file streams.
// The XSD, XML, and EXE must be in the same directory.
xmlFileName = strAppPath + "\\Tools.xml";
FileStream FsXML = new FileStream(xmlFileName,FileMode.Open);
// Load the data into the DataSet.
XmlTextReader xtrXML = new XmlTextReader(FsXML);
toolDS.ReadXml(xtrXML);
xtrXML.Close();
FsXML.Close();
// Get a DataTable to conveniently use for binding.
DataTable dt = toolDS.Tables["Tools"];
//Bind the ListBox to the tools
lstTools.DataSource = dt;
lstTools.DisplayMember = "Tool";
}
My xml file...
<?xml version="1.0" encoding="utf-8" ?>
<Tools>
<Tool>Tool #1</Tool>
<Tool>Tool #2</Tool>