Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2387
How to enable adding rows in the grid
posted

I cannot figure out how to get the UltraGrid to enable adding a row to the dataset.  As to make sure that there was not something wrong with my custom objects I put together a test that has both the UltraGrid and the standard Microsoft DataGrid, which is allowing the add at the bottom.

WindowsFormsApplication1.zip
  • 37774
    Verified Answer
    posted

    If you want to get the TemplateAddRow to display in the UltraGrid, you need to set the grid.DisplayLayout.Override.AllowAddNew to TemplateOnTop or TemplateOnBottom.  With that being said, however, there still seems to be some issues with your data source.  I can't get the .NET DataGrid to work correctly with the AddNewRow either.  The problem seems to be with your override of AddNewCore, mainly that you're never actually adding the new item to the list.  I think that your best option here is to do what the base BindingList<T> class does and call the base implementation of the Add method with the object that you create:

    protected override object AddNewCore()
    {
        int cnt = this.Items.Count;
        ChoiceSetOption newObject = new ChoiceSetOption(cnt, "<Add Text>");
        base.Add(newObject);

        return newObject;
    }

    -Matt