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
75
Adding a new row at the top of the UltraGrid via data binding
posted

Hello,

We have a Windows Form control that consists of a form at the top and an UltraGrid below.  The user inputs data via the form up top, hits a button, and adds a new row to the grid with the data contained in the form -- nothing too fancy here.  Our problem is that we want the newly added row to appear at the top of the grid, or, if this is not an option, we would like to scroll the newly added row into view.  I've seen a previous thread that deals with this logic, but only when the row is added to the UltraGrid itself -- in our situation, we always add the row to the data source -- in this case, a typed DataSet -- which we've bound to the UltraGrid.  We went with this because of the strong typing of the DataSet in this situation, but as a result we don't have a reference to the row in the UltraGrid to work with.

Any ideas?  Is adding the row to the grid directly the only way to go?

Thanks in advance.

  • 469350
    Offline posted

    Hi,

    What part of this are you having trouble with?

    If you are adding the row to the root band in the grid, then you can assume that the row will appear as the last row in the grid's Rows collection. So it should be easy to get a reference to the newly-added row and then use the methods on the ActiveRowScrollRegion to scroll the row into view or to the top.

    If you are adding a row to the child band, then this becomes much more difficult, You would have to somehow find the grid row based on it's parent chain in the data source. There's no super-easy way to do this, you would have to write code to search the grid rows based on what you know about the newly-added child row.