It is not rare that one need to read structured data from files like
x1 y1 z1
Surely you can read it to memory using StreamReader, and the Readline method etc, however this is cumbersome.
C# provides an easy way to to this:
public static DataView ReadCommandSet(string CmdSetFile)
DataSet set1 = new DataSet();
// Get a DataView of the table contained in the dataset.
The DataView can be then bound to a DataGridView
|CmdBindingSource.DataSource = ReadCommandSet(…);
CmdDataGridView.DataSource = CmdBindingSource;
CmdDataGridView.Columns.Width = 200;
CmdDataGridView.Columns.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
To filter the data:
|CmdBindingSource.Filter = “SomeColumnName LIKE ‘*KeyWords*’ “;|
One more question, if the original text is in a txt or other format, then what? Well, there are a lot of tools to convert them to XML files, say for instance, Altova XML tools. You can import the file, view in the grid mode, and then give the data column some tags, such as “X”, “Y” and “Z”, which will be used in the XML for the description of the data.
The benifit of such processing is that you don’t need to implement the IBindingListView interface support filtering, which costs tens of lines of code. This is neat, isn’t it?