Home Forums WPF controls Xceed DataGrid for WPF Inserting a row

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #26639 |

    Hello

    I have a datasource that inherits ObservableCollection and implements IBindingList.

    When i click on the insertion row a new obect goe sinto edit mode. But when i hit the enter button all the data entered into the cells is lost and a blank object is added into the datasource.

    I can then go and edit the row but when the row is added, all it’s data is lost.

    I’m not sure what i am doing wrong.

    Cheers

    alan

    Imported from legacy forums. Posted by Alan (had 2867 views)

    Xceed Support
    Member
    Post count: 5658

    Can you post your implementation of IBindingList.AddNew and Add?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 231 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny

    I have made a of changes

    public void Add(object value)
    {
    this.Items.Add((Customer)value);
    }

    public object AddNew()
    {

    Customer temp = new Customer();
    this.Add(temp);
    return temp;
    }

    When debugging the objects are in the item collection, but the datagrid isn’t refreshing, so no rows are appearing.

    Do i need to rebind my control??

    cheers

    Alan

    Imported from legacy forums. Posted by Alan (had 400 views)

    User (Old forums)
    Member
    Post count: 23064

    well i have it working i can’t say i’m happy with the implementation. Could you point me to some sort of best practise??

    public void Add(object value)
    {
    this.Items.Add((Customer)value);
    ListChanged(this, new ListChangedEventArgs(ListChangedType.ItemAdded, this.Count – 1));
    }

    public object AddNew()
    {
    Customer temp = new Customer();
    this.Add(temp);
    return temp;
    }

    Cheers

    Alan

    Imported from legacy forums. Posted by Alan (had 4044 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.