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
115
Howto tell the Grid that TemplateAddRow has changed?
posted

I want to tell the grid that the addrow has been modified and should be added after leaving.

Background is my object is most of the time filled the correct values. The user only should look and check Maybe modify the the addrow, if it is modified everything works fine, but if not the grid discards the row and deletes it. So how can i tell the grid row that it is modified?

  • 469350
    Verified Answer
    Offline posted

    The TemplateAddRow is a special row and it has some very specific behavior. 

    It displays in the grid, and if it's not modified directly by the user, the grid assumes that the row is not valid and it has no corresponding row in the data source and so the grid cancels it. This is true even if you modify the cells values of that row in code. 

    If you want to simulate a user-modification of the TemplateAddRow, then you can set the AddRowModifiedByUser property on the rows collection to true. So for the root band, that would look like this:

    this.ultraGrid1.Rows.AddRowModifiedByUser = true;

    This will make the TemplateAddRow into a regular AddRow as if the user had modified the row and thus it will create another TemplateAddRow. So you may only want to do this when you are about to commit your data. 

    You can also get the TemplateAddRow from the rows collection: 

    this.ultraGrid1.Rows.TemplateAddRow

    and check the IsUnmodifiedTemplateAddRow to see if the row is still unmodified by the user.

    this.ultraGrid1.Rows.TemplateAddRow.IsUnmodifiedTemplateAddRow

    But, in theory, I think this will always be true because once the row is modified, it's no longer a TemplateAddRow.