!!!Displaying data in grid!!!

G

Greg

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?
 
K

Kai Brinkmann [MSFT]

There is no reason you cannot use a dataGrid control. The data in the
dataSet used as the source for the grid does not have to come from a
database! A dataSet object is simply an internal representation of a set of
data, but this data can come from anywhere you want. You can create data
tables for your data programmatically, add them to a dataSet (e.g.
dsMyDataSet.Tables.Add(myTable)) and then use this as the data source for a
dataGrid control.

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

Alexander

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.
 
R

Rookie

Hi Greg,

I am a newbie too. But not a long while ago I too was looking for a
control like that and the ListView control served my purpose. The
ListView control has a property called View. Set this to Details and
it gives the functionality of a Grid.

HTH.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top