Greg said:
I need to display data (that is not in a database!) in a
grid format , and I cannot find a grid control to do
this!!! I know of the datagrid, but this has to link to a
dataset and database.
I know of the MS flexigrid (which doesn't appear in my
resources???), but this apparently has to have a license.
Where can I find out about this?
I used the Datagrid for this. You dont have to have a database for it
if you construct the data source by yourself. Here is a slightly
stripped example of what I did to use a simple XML string as a source.
I just inherited from the Datagrid and added a new Property XmlData
like this:
public override string Text
{
set
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(value);
XmlNode rootNode = xmlDoc.FirstChild;
DataTable dataTable = new DataTable();
for (int i = 0; i<rootNode.FirstChild.ChildNodes.Count; i++)
dataTable.Columns.Add(new string(' ', i+1));
foreach (XmlNode row in rootNode.ChildNodes)
{
DataRow dataRow = dataTable.NewRow();
int col = 0;
foreach (XmlNode column in row.ChildNodes)
{
dataRow[col] = column.FirstChild.Value;
col++;
}
dataTable.Rows.Add(dataRow);
}
this.DataSource = dataTable;
this.Refresh();
}
}
So you can simple give the new Datagrid a String like this:
<Data>
<Row><Col1>data1</Col1><Col2>data2</Col2></Row>
<Row><Col1>data1</Col1><Col2>data2</Col2></Row>
</Data>
and it will display it in the Grid.