Skip to main content

how to add new row between existing two rows.

Comments

1 comment

  • Dapfor Team

    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,
    Dapfor

    0

Please sign in to leave a comment.

Powered by Zendesk