how to add new row between existing two rows.
Hello,
1. How to add new row between existing two rows. I add grid.row[1].add is only for hierarchical row. I don't want hierarchical row.
2. how to add double value to cell.Value. It's only accept String. For sorting, I need to change cell value to double or decimal.
3. I'm inserting data to gird as cell.Value = stringvalue;
It is okay for value is string type.
But I got below error when I insert the value with cell.value = doublevalue;
An unhandled exception of type 'System.InvalidCastException' occurred in Dapfor.Net.dll
Additional information: Object cannot be stored in an array of this type.
Regards,
-
Hello,
1. Just add a new row to the grid and then change its child index:
Row row = grid.Rows.Add(yourData);
row.ChildIndex = firstRow.ChildIndex + 1;
Read more about indexing in the grid: http://www.dapfor.com/Help/NetGrid/html/06ac87ec-0a13-4504-ac2a-3a589d2a9bea.htm
2. Cell.Value accepts values of any types. How do you populate the grid and what data types do you use? If you use objects of custom classes, just change a property type returning prices.
3. This means that you use string types in data objects. How do you add data to the grid?
If you use something like grid.Rows.Add(new string[] {...}), you'll get InvalidCastException exception, If you use grid.Rows.Add(new object[] {...}) this should work. But again, it is much better if you use objects of custom classes:grid.Rows.Add(new MyDataObject());
class MyDataObject : INotifyPropertyChanged
{
decimal Price {get; set;}
...
}
Then you can change values directly in your objects without calling grid's API. All changies will be reflected automatically even in the grouped/sorted/filtered grid. Of course you can call grid.Rows[0]["Price"] = 1.23m, but you should keep in mind that the grid can have sorting/grouping/filtering and visible index of the row can change.
Regards,
Dapfor0
Please sign in to leave a comment.
Comments
1 comment