I have a simple object named Category that looks something like this. (I simplified the property methods for brevity.)
public class Category {
public string Name { get; set; }
public string ShortName {get; set; }
public string CreateDate { get; set; }
public string ModifiedDate { get; set; }
I'd like to show items like this in a grid with four columns; one for each property. I originally tried doing the following:
Node categoryNode = new Node(categoryObject);
grid.Rows.Items.Add(categoryNode);
categoryNode[columnName] = category.Name;
categoryNode[columnShortName] = category.ShortName;
categoryNode[columnCreateDate] = category.CreateDate;
categoryNode[columnModifiedDate] = category.ModifiedDate;
This led to some rather strange behavior in that only the first column ever had it's value set. It actually overwrote the value, so that whatever was set last with categoryNode[columnX], was what appeared in the column. After looking through the examples, I was able to find that if I did the following, the grid displayed as expected:
Node categoryNode = new Node(new object[] {category.Name, category.ShortName, category.CreateDate, category.ModifiedDate});
My problem with this is that it seems I'll have to know when adding a row how many columns my grid has, and in what order they would appear. I'd also have to have a hidden column in order to store the actual object so that I could use it later on in another operation. Is there something I'm missing here? I'd like very much for the Node to be able to have a single value, but be able to have the columns represent different properties of that object. Thanks in advance for any help anyone can provide!