Data type/structure for merging data in a datagridview
I开发者_运维技巧 have a currently have the user input a tag, I get the values for that tag (which are a timestamp/value pair) into a datagridview. I'd like the option to add multiple tags which would each get a column in the datagridview with only a single timestamp column, which would hold merged timestamps.
I currently have this:
Tag = ...
...//TagVals are the values (timestamp/value pairs) for the tag
TagVals = tag.Values; //pseudo
foreach(var val in TagVals)
{
object[] vals = new object[2];
vals[0] = val.timestamp;
vals[1] = val.value;
datagridview1.Rows.Add(vals)
}
But i'd like to have multiple tags in the same datagridview, so I need something like this:
foreach(var tag in Tags)
{
...//TagVals are the values (timestamp/value pairs) for the tag
TagVals = tag.Values; //pseudo
foreach(var val in TagVals)
{
//?? object[] vals = new object[2];
//?? vals[0] = val.timestamp;
//?? vals[1] = val.value;
//?? datagridview1.Rows.Add(vals)
}
}
assuming the TagVals contain these timestamp value pairs (where the 1.x values are coming from the first tag, and the 2.x values are coming from the second tag):
2:00 | 1.1
2:20 | 1.2
2:40 | 1.3
2:00 | 2.1
2:30 | 2.2
2:40 | 2.3
2:50 | 2.4
I want my datagridview to look like this:
2:00 | 1.1 | 2.1
2:20 | 1.2 |
2:30 | | 2.1
2:40 | 1.3 | 2.3
2:50 | | 2.4
What is the best data structure/type to use to hold these values, and to merge them into the datagrid view?
精彩评论